-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1055A.c
More file actions
43 lines (42 loc) · 770 Bytes
/
Copy path1055A.c
File metadata and controls
43 lines (42 loc) · 770 Bytes
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
#include<stdio.h>
int main(){
int n,s;
scanf("%d %d",&n,&s);
int a[n];
int b[n];
int flag=0;
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]==0){
flag=1;
}
}
for(int i=0;i<n;i++){
scanf("%d",&b[i]);
}
if(a[0]==0){
printf("NO\n");
}
else if(flag==0){
printf("YES\n");
}
else if (a[0]==1 && a[s-1]==1){
printf("YES\n");
}
else{
int count=0;
for(int i=n-1;i>s-1;i--){
if(a[i]==1 && b[i]==1 && b[s-1]==1){
count=1;
break;
}
}
if(count==1){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return 0;
}