Submission #130464

#TimeUsernameProblemLanguageResultExecution timeMemory
130464onjo0127Information (CEOI08_information)C++11
100 / 100
227 ms20456 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int N, M, in[2009], ou[2009], t; vector<pii> adj[2009], R[2009]; bool v1[2009], v2[2009]; int h[1000009]; bool isup(int u, int v) { return in[u] <= in[v] && ou[u] >= ou[v]; } void dfs(int x) { in[x] = ++t; v1[x] = 1; for(auto& it: adj[x]) { if(!v1[it.first]) { h[it.second] = 1; dfs(it.first); } } ou[x] = t; } void go(int x) { v2[x] = 1; for(auto& it: adj[x]) { int t, i; tie(t, i) = it; if(!v2[t]) { if(h[i] == 0) { h[i] = 2; go(t); } else if(h[i] == 1 && R[t].size()) { int rt, ri; tie(rt, ri) = R[t].back(); R[t].pop_back(); h[i] = 2; h[ri] = 1; go(t); } } } } int main() { scanf("%d%d",&N,&M); for(int i=1; i<=M; i++) { int u, v; scanf("%d%d",&u,&v); adj[u].push_back({v, i}); } dfs(1); for(int i=1; i<=N; i++) { for(auto& it: adj[i]) { if(!h[it.second] && !isup(it.first, i)) R[it.first].push_back({i, it.second}); } } go(1); vector<int> A1, A2; for(int i=1; i<=N; i++) for(auto& it: adj[i]) { if(h[it.second] == 1) A1.push_back(it.second); if(h[it.second] == 2) A2.push_back(it.second); } if((int)A1.size() != N-1 || (int)A2.size() != N-1) puts("NONE"); else { for(auto& it: A1) printf("%d ",it); puts(""); for(auto& it: A2) printf("%d ",it); } return 0; }

Compilation message (stderr)

information.cpp: In function 'int main()':
information.cpp:64:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   for(auto& it: A1) printf("%d ",it); puts("");
   ^~~
information.cpp:64:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   for(auto& it: A1) printf("%d ",it); puts("");
                                       ^~~~
information.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&N,&M);
  ~~~~~^~~~~~~~~~~~~~
information.cpp:47:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int u, v; scanf("%d%d",&u,&v);
             ~~~~~^~~~~~~~~~~~~~
#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...