# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
788223 | 2023-07-20T02:47:30 Z | Username4132 | Povjerenstvo (COI22_povjerenstvo) | C++14 | 3000 ms | 79628 KB |
#include<iostream> #include<vector> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define PB push_back const int MAXN = 500010; bool del[MAXN], vis[MAXN], ans[MAXN]; int n, m, cn; vector<int> g[MAXN], gi[MAXN]; void dfs(int v, bool flag){ vis[v]=true; ans[v]=flag; for(int to:gi[v]){ del[to]=true; if(!vis[to]) dfs(to, !flag); } } int main(){ scanf("%d %d", &n, &m); forn(i, m){ int a, b; scanf("%d %d", &a, &b); --a, --b; g[a].PB(b), gi[b].PB(a); } while(true){ int v=-1; forn(i, n) if(!del[i]) v=i; if(v==-1) break; forn(i, n) vis[i]=false; while(!g[v].empty() && !vis[g[v].back()]) v=g[v].back(), vis[v]=true; forn(i, n) vis[v]=false; del[v]=true; dfs(v, true); } forn(i, n) cn+=ans[i]; printf("%d\n", cn); forn(i, n) if(ans[i]) printf("%d ", i+1); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 172 ms | 79628 KB | Output is correct |
2 | Correct | 175 ms | 59240 KB | Output is correct |
3 | Correct | 11 ms | 23796 KB | Output is correct |
4 | Execution timed out | 3065 ms | 24252 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 174 ms | 79472 KB | Output is correct |
2 | Execution timed out | 3095 ms | 41252 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 24280 KB | Output is correct |
2 | Correct | 22 ms | 23996 KB | Output is correct |
3 | Correct | 12 ms | 24020 KB | Output is correct |
4 | Execution timed out | 3085 ms | 24000 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 172 ms | 79628 KB | Output is correct |
2 | Correct | 175 ms | 59240 KB | Output is correct |
3 | Correct | 11 ms | 23796 KB | Output is correct |
4 | Execution timed out | 3065 ms | 24252 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |