fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 5;
  5.  
  6. int main() {
  7. int size, array[MAX_SIZE + 1];
  8. cin >> size;
  9. for (int i = 1; i <= size; ++i) {
  10. cin >> array[i];
  11. }
  12. int mt[MAX_SIZE + 1][MAX_SIZE + 1], sameColsNo = 0;
  13. for (int line = 1; line <= size; ++line) {
  14. for (int col = 1; col <= size; ++col) {
  15. cin >> mt[line][col];
  16. if (array[line] == mt[line][col]) {
  17. mt[line][col] = 1;
  18. } else {
  19. mt[line][col] = 0;
  20. }
  21. mt[line][col] += mt[line - 1][col];
  22. if (line == size && mt[line][col] == size) {
  23. ++sameColsNo;
  24. }
  25. }
  26.  
  27. }
  28. if (sameColsNo >= 2) {
  29. cout << "DA";
  30. } else {
  31. cout << "NU";
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0s 5280KB
stdin
5
1 3 4 6 7
1 1 1 1 1
2 6 4 7 1
4 4 4 4 4
6 6 6 6 6
7 7 7 7 7
	NU
stdout
NU