-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA 1055 - Metro.java
46 lines (41 loc) · 1.39 KB
/
A 1055 - Metro.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.Scanner;
public class Metro {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[][] data = new int[2][input.nextInt()];
int x = input.nextInt();
boolean isFinish = false;
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[i].length; j++) {
data[i][j] = input.nextInt();
}
}
if (data[0][0] == 1) {
for (int j = x - 1; j < data[0].length; j++) {
if (j == x - 1) {
if (data[0][j] == 1) {
System.out.println("YES");
isFinish = true;
break;
} else if (data[1][j] == 0) {
System.out.println("NO");
isFinish = true;
break;
}
} else if (data[0][j] == 1) {
if (data[1][j] == 1) {
System.out.println("YES");
isFinish = true;
break;
}
}
}
} else {
System.out.println("NO");
isFinish = true;
}
if(isFinish == false){
System.out.println("NO");
}
}
}