Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************
- * Problem: 3986. Sources and sinks
- * Theme: Graphs
- */
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define mp make_pair
- #define pb push_back
- #define ALL(A) A.begin(),A.end()
- #define RALL(A) A.rbegin(),A.rend()
- #define FOR(i,a,b) for(int i=(a);i<(b);i++)
- typedef vector<int> VI;
- typedef vector<pair<int,int> > VII;
- typedef vector<VI> VVI;
- const long double PI=acos(-1);
- const int INF=(int)1e18;
- const int MOD=(int)1e9+7;
- const int N = 1e3;
- int m[101][101];
- signed main()
- {
- ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- //freopen("reform.in","r",stdin);
- //freopen("reform.out","w",stdout);
- int n;
- cin >> n;
- VI v1;
- VI v2;
- for(int i=0;i<n;i++)
- {
- bool al=1;
- for(int j=0;j<n;j++)
- {
- cin >> m[i][j];
- if(m[i][j])
- al=0;
- }
- if(al)
- v1.pb(i+1);
- }
- for(int i=0;i<n;i++)
- {
- bool al=1;
- for(int j=0;j<n;j++)
- {
- if(m[j][i])
- al=0;
- }
- if(al)
- v2.pb(i+1);
- }
- cout << v2.size() << " ";
- for(auto x : v2)
- cout << x << " ";
- cout << "\n";
- cout << v1.size() << " ";
- for(auto x : v1)
- cout << x << " ";
- cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement