Advertisement
Ankit_132

B

May 1st, 2024
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int t;
  6.     cin>>t;
  7.     while(t--)
  8.     {
  9.         int n, k; cin >> n >> k;
  10.        
  11.         vector <int> chk(k, 0);
  12.         for (int i = 0; i < n; i++){
  13.             string str; cin >> str;
  14.            
  15.             int cnt = 0;
  16.             for (auto x : str) cnt += x == '1';
  17.            
  18.             if (cnt == 1){
  19.                 int x = -1;
  20.                 for (int j = 0; j < k; j++) if (str[j] == '1') x = j;
  21.                
  22.                 chk[x] = true;
  23.             }
  24.         }
  25.  
  26.     int f = 1;
  27.        
  28.         for (auto x : chk) if (!x){
  29.             cout << "No\n";
  30.         f = 0;
  31.             break;
  32.         }
  33.  
  34.     if(f)
  35.         cout << "Yes\n";
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement