Created
March 31, 2020 17:29
-
-
Save belushkin/ce8520322794eec76c7db1b50eda4d2f to your computer and use it in GitHub Desktop.
Exercising Walk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n = Integer.parseInt(sc.nextLine()); | |
for (int i = 0; i < n; i++) { | |
String s = sc.nextLine(); | |
String[] result = s.split(" "); | |
int a = Integer.parseInt(result[0]); | |
int b = Integer.parseInt(result[1]); | |
int c = Integer.parseInt(result[2]); | |
int d = Integer.parseInt(result[3]); | |
s = sc.nextLine(); | |
result = s.split(" "); | |
int x = Integer.parseInt(result[0]); | |
int y = Integer.parseInt(result[1]); | |
int x1 = Integer.parseInt(result[2]); | |
int y1 = Integer.parseInt(result[3]); | |
int x2 = Integer.parseInt(result[4]); | |
int y2 = Integer.parseInt(result[5]); | |
x += b-a; | |
y += d-c; | |
if (a+b > 0 && x1 == x2) { | |
System.out.println("NO"); | |
} else if (c+d > 0 && y1 == y2) { | |
System.out.println("NO"); | |
} else if(x >= x1 && x <= x2 && y >= y1 && y <= y2) { | |
System.out.println("YES"); | |
} else { | |
System.out.println("NO"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment