Advertisement
kadeyrov

Untitled

Nov 22nd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  olymp_in
  4. //
  5. //  Created by Kadir Kadyrov on 19.10.2020.
  6. //  Copyright © 2020 Kadir Kadyrov. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <algorithm>
  11. #include <string>
  12. #include <cstdio>
  13. #include <queue>
  14. #include <map>
  15. #include <vector>
  16. #include <stack>
  17.  
  18.  
  19. using namespace std;
  20.  
  21. int main() {
  22.     int n;
  23.     cin >> n;
  24.    
  25.     int a[n][n];
  26.    
  27.     for (int i = 0; i < n; i++) {
  28.         for (int j = 0; j < n; j++) {
  29.             cin >> a[i][j];
  30.         }
  31.     }
  32.    
  33.     vector<int> stok, istok;
  34.    
  35.     for (int i = 0; i < n; i++) {
  36.         bool isIstok = true, isStok = true;
  37.         for (int j = 0; j < n; j++) {
  38.             if(a[i][j] == 1)
  39.                 isIstok = false;
  40.             if (a[j][i] == 1)
  41.                 isStok = false;
  42.         }
  43.        
  44.         if(isIstok == true)
  45.             istok.push_back(i);
  46.         if(isStok == true)
  47.             stok.push_back(i);
  48.     }
  49.    
  50.     cout << stok.size() << ' ';
  51.     for (int i = 0; i < stok.size(); i++) {
  52.         cout << stok[i] + 1 << ' ';
  53.     }
  54.     cout << endl;
  55.    
  56.     cout << istok.size() << ' ';
  57.     for (int i = 0; i < istok.size(); i++) {
  58.         cout << istok[i] + 1 << ' ';
  59.     }
  60.     cout << endl;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement