Advertisement
Infiniti_Inter

Untitled

Dec 15th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include<iostream>
  2. #include<math.h>
  3. using namespace std;
  4.  
  5. const int N = 1e4;
  6.  
  7. bool used[N][N];
  8.  
  9. int a[N][N];
  10. int answer[2 * N];
  11.  
  12. int main()
  13. {
  14. int n;
  15. cin >> n;
  16. for (int i = 0; i < n; ++i)
  17. for (int j = 0; j < n; ++j)
  18. cin >> a[i][j];
  19. int cnt = 0;
  20. for (int j = 0; j < n; ++j)
  21. for (int i = 0; i < n; ++i)
  22. {
  23. int cur = a[i][j];
  24. if (used[j][cur] == true)
  25. {
  26. for (int k = 0; k < i; k++)
  27. if (a[k][j] == cur)
  28. {
  29. answer[cnt++] = k;
  30. break;
  31. }
  32. answer[cnt++] = i;
  33. break;
  34. }
  35. else
  36. used[j][cur] = true;
  37. }
  38. for (int i = 0; i < cnt; i += 2)
  39. cout << answer[i] + 1<< ' ' << answer[i + 1] + 1 << endl;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement