fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // The GOAT ^_^
  5. int main() {
  6. int n, m;
  7. cin >> n >> m;
  8. int arr[n][m];
  9.  
  10. for (int i = 0; i < n; i++) {
  11. for (int j = 0; j < m; j++) {
  12. cin >> arr[i][j];
  13. }
  14. }
  15.  
  16. int x;
  17. cin >> x;
  18. for (int i = 0; i < n; i++) {
  19. for (int j = 0; j < m; j++) {
  20. if (arr[i][j] == x) {
  21. cout << "YES" << endl;
  22. return 0;
  23. }
  24. }
  25. }
  26. cout << "NO" << endl;
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5320KB
stdin
2 2
1 2
3 4
10
stdout
NO