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 = 1e5 + 5;
  17.  
  18.  
  19. signed main(){
  20. Free_palestine();
  21. int n,m; cin>>n>>m;
  22. int arr[n][m];
  23.  
  24. for(int i = 0; i < n; i++){
  25. for(int j = 0; j < n; j++){
  26. cin>>arr[i][j];
  27. }
  28. }
  29. int x; cin>>x;
  30.  
  31. for(int i = 0; i < n; i++){
  32. for(int j = 0; j < n; j++){
  33. if (arr[i][j] == x) {
  34. cout<<"YES"<<endl;
  35. return 0;
  36. }
  37. }
  38. }
  39. cout<<"NO"<<endl;
  40. }
Success #stdin #stdout 0s 5320KB
stdin
2 2
1 2
3 4
10
stdout
NO