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, res, x , y, k;
- set< pair<long long, long long> > s;
- int main(){
- cin>>n;
- x=0; y=0;
- s.insert({x, y});
- 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" << endl << abs(x)+abs(y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement