Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long long i,n,k,res,y,x;
- set< pair< long long , long long > > s;
- int main() {
- cin>>n;
- res=0;
- s.insert( {0,0} );
- for(i=1;i<=n;i++){
- cin>>k;
- if(k==1){y++; x--;}
- if(k==2){y++;}
- if(k==3){y++; x++;}
- if(k==4){x++;}
- if(k==5){y--; x++;}
- if(k==6){ y--;}
- if(k==7){y--; x--;}
- if(k==8){x--;}
- if(s.count( {x,y} )==1) {
- res=i;
- break;
- } else s.insert( {x,y} );}
- if(res!=0) cout<<res;
- else cout<<"Ok"<<" "<<abs(x)+abs(y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement