Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <map>
  2. #include <iostream>
  3. #include <vector>
  4. #include <queue>
  5. #include <stack>
  6. #include <cstdio>
  7. #include <algorithm>
  8. #define S second
  9. #define F first
  10. #define $ ios::sync_with_stdio(0);
  11. #define pb push_back
  12. #define oo 999999999999999
  13. #define MAXN 1123456
  14. using namespace std;
  15. typedef map<int, int> mii;
  16. typedef long long int ll;
  17. typedef pair<int, int> ii;
  18. typedef vector<int> vi;
  19. typedef vector<vi> graph;
  20. //ll v[MAXN], sum[MAXN];
  21. int mat[7][7];
  22. int dx[] = {1,0,-1,0,1};
  23. int main()
  24. {$
  25.     int n,m, a, b, c, k,x,y;
  26.     string s;
  27.     for(int i = 0;i<6; ++i)
  28.         mat[0][i]=mat[i][0] =mat[6][i] = mat[i][6] = 1;
  29.     cin>>n;
  30.     queue<ii> q;
  31.    
  32.     while(n--)
  33.     {
  34.         for(int i =1; i<=5; ++i)
  35.             for(int j =1; j<=5; ++j)
  36.                 cin>>mat[i][j];
  37.         q.push(ii(1,1));
  38.         mat[1][1]=2;
  39.         while(!q.empty())
  40.         {
  41.             x = q.front().F;
  42.             y = q.front().S;
  43.             q.pop();
  44.             for(int i = 0; i<4; ++i)
  45.             {
  46.                 a = x+dx[i];
  47.                 b = y+dx[i+1];
  48.                 if(!(mat[a][b]))
  49.                     q.push(ii(a,b)),mat[a][b]=2;
  50.             }
  51.         }
  52.  
  53.         if(mat[5][5]==2)
  54.             cout<<"COPS\n";
  55.         else
  56.             cout<<"ROBBERS\n";
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement