Submission #660358

#TimeUsernameProblemLanguageResultExecution timeMemory
660358Dec0DeddInformation (CEOI08_information)C++14
8 / 100
593 ms31548 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], n, m; bool vis[N]; vector<pii> G[N], GT[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 { bool ok=false; for (auto z : GT[u.first]) { if (c[z.second] == 0) { ok=true; c[z.second]=1; } } if (ok) { c[u.second]=2; 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}); GT[b].push_back({a, i}); } dfs(1); memset(vis, false, sizeof(vis)); 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...