Submission #660354

#TimeUsernameProblemLanguageResultExecution timeMemory
660354Dec0DeddInformation (CEOI08_information)C++14
8 / 100
505 ms12340 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> const int N = 2e3+1; const int M = 1e6+1; int c[M], fr[N], n, m; bool vis[N]; vector<pii> G[N]; void dfs(int v) { vis[v]=true; for (auto u : G[v]) { if (vis[u.first]) continue; c[u.second]=1, dfs(u.first); } } void dfs2(int v) { vis[v]=true; for (auto u : G[v]) { if (vis[u.first]) continue; if (c[u.second] == 0) { c[u.second]=2; dfs2(u.first); } else { if (fr[u.first] > 1) { c[u.second]=2; --fr[u.first]; dfs2(u.first); } } } } int main() { cin>>n>>m; for (int i=1; i<=m; ++i) { int a, b; cin>>a>>b; G[a].push_back({b, i}); } dfs(1); memset(vis, false, sizeof(vis)); for (int i=1; i<=n; ++i) { for (auto u : G[i]) { if (c[u.second] == 0) ++fr[u.first]; } } dfs2(1); vector<int> l, r; for (int i=1; i<=m; ++i) { if (c[i] == 1) l.push_back(i); else if (c[i] == 2) r.push_back(i); } if ((int)l.size() < n-1 || (int)r.size() < n-1) cout<<"NONE\n"; else { for (auto u : l) cout<<u<<" "; cout<<"\n"; for (auto u : r) cout<<u<<" "; cout<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...