Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int n,m;
  5. char field[3001][3001];
  6. int main()
  7. {
  8.     ios::sync_with_stdio(false);
  9.     cin.tie(0);
  10.     cout.tie(0);
  11.     freopen("ROWCUT.inp","r",stdin);
  12.     freopen("ROWCUT_trau.out","w",stdout);
  13.     cin >> n >> m;
  14.     for (int i=1;i<=n;i++)
  15.         for (int j=1;j<=m;j++)
  16.             cin >> field[i][j];
  17.     int res = 0;
  18.     for (int i=1;i<=n;i++)
  19.     {
  20.         bool ok = false;
  21.         string tmp;
  22.         for (int j=1;j<=n-i;j++)
  23.             tmp+=field[j][1];
  24.         for (int j=2;j<=m;j++)
  25.         {
  26.             string o_tmp;
  27.             for (int k=1;k<=n-i;k++)
  28.                 o_tmp += field[k][j];
  29.             if (o_tmp == tmp)
  30.             {
  31.                 ok = true;
  32.                 break;
  33.             }
  34.         }
  35.         if (ok) break;
  36.         res = i;
  37.     }
  38.     if (!res) cout << -1;
  39.     else cout << res;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement