Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n,m;
- char field[3001][3001];
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- freopen("ROWCUT.inp","r",stdin);
- freopen("ROWCUT_trau.out","w",stdout);
- cin >> n >> m;
- for (int i=1;i<=n;i++)
- for (int j=1;j<=m;j++)
- cin >> field[i][j];
- int res = 0;
- for (int i=1;i<=n;i++)
- {
- bool ok = false;
- string tmp;
- for (int j=1;j<=n-i;j++)
- tmp+=field[j][1];
- for (int j=2;j<=m;j++)
- {
- string o_tmp;
- for (int k=1;k<=n-i;k++)
- o_tmp += field[k][j];
- if (o_tmp == tmp)
- {
- ok = true;
- break;
- }
- }
- if (ok) break;
- res = i;
- }
- if (!res) cout << -1;
- else cout << res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement