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