# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130426 | 2019-07-15T07:49:42 Z | 이온조(#3149) | Information (CEOI08_information) | C++14 | 224 ms | 20476 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 3320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 4248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 2620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 224 ms | 20476 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 200 ms | 17144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 217 ms | 17768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 632 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |