Submission #660326

#TimeUsernameProblemLanguageResultExecution timeMemory
660326Dec0DeddInformation (CEOI08_information)C++14
42 / 100
1095 ms9580 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> const int N = 2e3+1; const int M = 1e6+1; bool us[M], vis[N]; vector<pii> G[N]; vector<int> l, r; int n, m; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); void dfs(int v) { vis[v]=true; shuffle(G[v].begin(), G[v].end(), rng); for (auto u : G[v]) { if (vis[u.first]) continue; us[u.second]=true; l.push_back(u.second); dfs(u.first); } } void dfs2(int v) { vis[v]=true; shuffle(G[v].begin(), G[v].end(), rng); for (auto u : G[v]) { if (vis[u.first] || us[u.second]) continue; r.push_back(u.second), dfs2(u.first); } } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>m; for (int i=1; i<=m; ++i) { int a, b; cin>>a>>b; G[a].push_back({b, i}); } int t=100, xr=0; while (t--) { memset(vis, false, sizeof(vis)); dfs(1); memset(vis, false, sizeof(vis)); dfs2(1); xr=max(xr, (int)r.size()); if ((int)l.size() == n-1 && (int)r.size() == n-1) break; l.clear(), r.clear(); } 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...