vitormartinotti

Untitled

May 7th, 2026
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main () {
  6.     int n; scanf("%d", &n);
  7.  
  8.     int dx[] = {0, 1, 2, 2, 1, -1, -2, -2, -1};
  9.     int dy[] = {0, 2, 1, -1, -2, -2, -1, 1, 2};
  10.  
  11.     int burx[] = {0, 1, 2, 2, 5};
  12.     int bury[] = {0, 3, 3, 5, 4};
  13.  
  14.     int cav[] = {4, 3}, c = 0;
  15.  
  16.     for(int k = 1; k <= n; k++){
  17.         int mov;
  18.         scanf("%d", &mov);
  19.         c++;
  20.         cav[0] += dx[mov];
  21.         cav[1] += dy[mov];
  22.         for(int i = 1; i <=4; i++){
  23.             if(cav[0] == burx[i] && cav[1] == bury[i]){
  24.                 printf("%d", c);
  25.                 return 0;
  26.             }
  27.         }
  28.     }
  29.     printf("%d", c);
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment