Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1.     cin>>n>>m;
  2.     char grid[n][m];
  3.     for(int i=0;i<n;i++){
  4.         for(int j=0;j<m;j++){
  5.             cin>>grid[i][j];
  6.         }
  7.        
  8.     }
  9.     int finalflag=0;
  10.     for(int k=0;k<m;k++){
  11.         vector<string> testing;
  12.         for(int i=0;i<n;i++){
  13.             string temp;
  14.             for(int j=0;j<m;j++){
  15.                 if(j!=k)
  16.                 temp=temp+grid[i][j];
  17.             }
  18.             testing.push_back(temp);
  19.         }  
  20.         int flag=0;
  21.         for(int i=0;i<n;i++){
  22.             for(int j=i+1;j<n;j++){
  23.                 if(testing[i]==testing[j])
  24.                 {
  25.                     flag=1;
  26.                     break;
  27.                 }
  28.             }
  29.             if(flag)
  30.             break;
  31.         }
  32.         if(flag)
  33.         {
  34.             finalflag=0;
  35.         }
  36.         else{
  37.             finalflag=1;
  38.             break;
  39.         }
  40.     }
  41.     if(finalflag)
  42.     cout<<"Yes\n";
  43.     else
  44.     cout<<"No\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement