Submission #1114685

#TimeUsernameProblemLanguageResultExecution timeMemory
1114685SalihSahinPovjerenstvo (COI22_povjerenstvo)C++14
100 / 100
228 ms65216 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; const int N = 5e5 + 5; vector<int> adj[N], adjrev[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin>>n>>m; for(int i = 0; i < m; i++){ int u, v; cin>>u>>v; adj[u].pb(v); adjrev[v].pb(u); } vector<int> ans; vector<int> nope(n+1); for(int i = 1; i <= n; i++){ if(!nope[i]){ ans.pb(i); for(auto itr: adjrev[i]) nope[itr] = 1; for(auto itr: adj[i]) nope[itr] = 1; } } cout<<ans.size()<<endl; for(auto itr: ans){ cout<<itr<<" "; } cout<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...