-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircle_metro.cpp
More file actions
76 lines (75 loc) · 1.24 KB
/
circle_metro.cpp
File metadata and controls
76 lines (75 loc) · 1.24 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,x,b,y;
cin>>n>>a>>x>>b>>y;
int ele1,ele2;
if(x>a){
ele1=x-a;
}
else{
ele1=n-(a-x);
}
if(y<b){
ele2=b-y;
}
else{
ele2=n-(y-b);
}
int arr[ele1+1],arr1[ele2+1],count=0,count1=0;
arr[0]=a,arr1[0]=b;
int i=1,j=1;
while(true){
if(a==x){
break;
}
if(arr[i-1]!=n){
arr[i]=a+1;
a+=1;
}
else{
arr[i]=1;
a=1;
}
count+=1;
i+=1;
}
while(true){
if(b==y){
break;
}
if(arr1[j-1]!=1){
arr1[j]=b-1;
b-=1;
}
else{
arr1[j]=n;
b=n;
}
count1+=1;
j+=1;
}
/*for(int ch: arr){
cout<<ch<<" ";
}cout<<"\n";
for(int ch1 : arr1){
cout<<ch1<<" ";
}cout<<"\n";*/
int m,ch=0;
if(ele1<ele2){
m=ele1+1;
}else{
m=ele2+1;
}
for(int i=0;i<m;i++){
if(arr[i]==arr1[i]){
cout<<"YES";
ch=1;
break;
}
}
if(ch==0){
cout<<"NO";
}
return 0;
}