Advertisement
welleyth

3986. Sources and sinks

Dec 26th, 2020
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. /********************
  2. * Problem: 3986. Sources and sinks
  3. * Theme: Graphs
  4. */
  5. #include <bits/stdc++.h>
  6.  
  7. using namespace std;
  8.  
  9. #define int long long
  10. #define mp make_pair
  11. #define pb push_back
  12. #define ALL(A) A.begin(),A.end()
  13. #define RALL(A) A.rbegin(),A.rend()
  14. #define FOR(i,a,b) for(int i=(a);i<(b);i++)
  15.  
  16. typedef vector<int> VI;
  17. typedef vector<pair<int,int> > VII;
  18. typedef vector<VI> VVI;
  19.  
  20. const long double PI=acos(-1);
  21. const int INF=(int)1e18;
  22. const int MOD=(int)1e9+7;
  23. const int N = 1e3;
  24.  
  25. int m[101][101];
  26.  
  27. signed main()
  28. {
  29.     ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  30.     //freopen("input.txt","r",stdin);
  31.     //freopen("output.txt","w",stdout);
  32.     //freopen("reform.in","r",stdin);
  33.     //freopen("reform.out","w",stdout);
  34.  
  35.     int n;
  36.     cin >> n;
  37.  
  38.     VI v1;
  39.     VI v2;
  40.  
  41.     for(int i=0;i<n;i++)
  42.     {
  43.         bool al=1;
  44.         for(int j=0;j<n;j++)
  45.         {
  46.             cin >> m[i][j];
  47.             if(m[i][j])
  48.                 al=0;
  49.         }
  50.         if(al)
  51.             v1.pb(i+1);
  52.     }
  53.  
  54.     for(int i=0;i<n;i++)
  55.     {
  56.         bool al=1;
  57.         for(int j=0;j<n;j++)
  58.         {
  59.             if(m[j][i])
  60.                 al=0;
  61.         }
  62.         if(al)
  63.             v2.pb(i+1);
  64.     }
  65.  
  66.     cout << v2.size() << " ";
  67.  
  68.     for(auto x : v2)
  69.         cout << x << " ";
  70.  
  71.     cout << "\n";
  72.  
  73.     cout << v1.size() << " ";
  74.  
  75.     for(auto x : v1)
  76.         cout << x << " ";
  77.  
  78.     cout << "\n";
  79.  
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement