fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 9;
  5. const int MAX_VAL = 20;
  6. int freq[MAX_VAL + 1];
  7.  
  8. int sameElmnt(int n, int m, int mt[][MAX_SIZE + 1]) {
  9. int counter;
  10. for (int i = 1; i <= n; ++i) {
  11. if (mt[i][n / 2 + 1] == mt[n / 2 + 1][i]) {
  12. ++counter;
  13. }
  14. }
  15. return counter;
  16. }
  17.  
  18. int main() {
  19. int n, m, mt[MAX_SIZE + 1][MAX_SIZE + 1];
  20. cin >> n >> m;
  21. for (int i = 1; i <= n; ++i) {
  22. for (int j = 1; j <= m; ++j) {
  23. cin >> mt[i][j];
  24. }
  25. }
  26. if (sameElmnt(n, m, mt) == n) {
  27. cout << "DA" << sameElmnt(n, m, mt);
  28. } else {
  29. cout << "NU" << sameElmnt(n, m, mt);
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5288KB
stdin
9 9 
1 2 3 9 9 6 7 8 9 
1 2 3 4 9 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
9 9 9 9 9 9 9 9 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 9 6 7 8 9 
stdout
NU4