fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define ld long double
  7.  
  8. void Free_palestine() {
  9. ios::sync_with_stdio(false);
  10. cin.tie(NULL);
  11. cout.tie(NULL);
  12. }
  13.  
  14. const int N = 2e5 + 5;
  15. const int MOD = 1e9 + 7;
  16. const int MAXN = 105;
  17. int a[MAXN][MAXN];
  18.  
  19. signed main(){
  20. Free_palestine();
  21.  
  22. int n, m; cin >> n >> m;
  23.  
  24. for (int i = 0; i < n; i++) {
  25. for (int j = 0; j < m; j++) {
  26. cin >> a[i][j];
  27. }
  28. }
  29.  
  30. int x;
  31. cin >> x;
  32.  
  33.  
  34. bool found = false;
  35. for (int i = 0; i < n; i++) {
  36. for (int j = 0; j < m; j++) {
  37. if (a[i][j] == x) {
  38. found = true;
  39. break;
  40. }
  41. }
  42. if (found) break;
  43. }
  44.  
  45. if (found) {
  46. cout << "YES\n";
  47. } else {
  48. cout << "NO\n";
  49. }
  50.  
  51. return 0;
  52. }
Success #stdin #stdout 0.01s 5316KB
stdin
2 2
1 2
3 4
10
stdout
NO