Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- using namespace std;
- const int N = 1e4;
- bool used[N][N];
- int a[N][N];
- int answer[2 * N];
- int main()
- {
- int n;
- cin >> n;
- for (int i = 0; i < n; ++i)
- for (int j = 0; j < n; ++j)
- cin >> a[i][j];
- int cnt = 0;
- for (int j = 0; j < n; ++j)
- for (int i = 0; i < n; ++i)
- {
- int cur = a[i][j];
- if (used[j][cur] == true)
- {
- for (int k = 0; k < i; k++)
- if (a[k][j] == cur)
- {
- answer[cnt++] = k;
- break;
- }
- answer[cnt++] = i;
- break;
- }
- else
- used[j][cur] = true;
- }
- for (int i = 0; i < cnt; i += 2)
- cout << answer[i] + 1<< ' ' << answer[i + 1] + 1 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement