Vserosbuybuy

C6. F

Apr 19th, 2021
1,515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <bitset>
  3. #include <vector>
  4. #include <map>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. #ifdef _DEBUG
  11.     freopen("input.txt", "r", stdin);
  12.     freopen("output.txt", "w", stdout);
  13. #endif // _DEBUG
  14.     int n, m, x;
  15.     cin >> n >> m;
  16.     vector<int> kn(n, 0);
  17.     for (int i = 0; i < n; ++i) {
  18.         for (int j = 0; j < m; ++j) {
  19.             cin >> x;
  20.             kn[i] *= 2;
  21.             kn[i] += x;
  22.         }
  23.     }
  24.  
  25.     int ans = 0;
  26.     for (int i = 0; i < (1 << n); ++i) {
  27.         int sum_kn = 0;
  28.         for (int j = 0; j < 22; ++j) {
  29.             if ((i & (1 << j)) != 0) {
  30.                 sum_kn |= kn[j];
  31.             }
  32.         }
  33.         if ((1 << m) - sum_kn == 1) {
  34.             ans++;
  35.         }
  36.     }
  37.  
  38.     cout << ans << "\n";
  39. }
Advertisement
Add Comment
Please, Sign In to add comment