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] = {0}, sameColsNo = 0;
  13. for (int line = 1; line <= size; ++line) {
  14. for (int col = 1; col <= size; ++col) {
  15. int currentEl;
  16. cin >> currentEl;
  17. if (array[line] == currentEl) {
  18. mt[line][col] = 1;
  19. }
  20. mt[line][col] += mt[line - 1][col];
  21. if (line == size && mt[line][col] == size) {
  22. ++sameColsNo;
  23. }
  24. }
  25.  
  26. }
  27. if (sameColsNo >= 2) {
  28. cout << "DA";
  29. } else {
  30. cout << "NU";
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 5288KB
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