# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
789049 | 2023-07-20T22:19:44 Z | Username4132 | Povjerenstvo (COI22_povjerenstvo) | C++14 | 89 ms | 47500 KB |
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define PB push_back const int MAXN = 200010; int n, m, cn; bool vis[MAXN], ans[MAXN]; vector<int> g[MAXN], gi[MAXN], order; void dfs1(int v){ vis[v]=true; for(int to:gi[v]) if(!vis[to]) dfs1(to); order.PB(v); } void dfs2(int v, bool flag){ vis[v]=true; if(flag){ ans[v]=true; for(int to:g[v]) ans[v]&=!ans[to]; } for(int to:g[v]) if(!vis[to]) dfs2(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); } forn(i, n) if(!vis[i]) dfs1(i); forn(i, n) vis[i]=false; reverse(order.begin(), order.end()); for(int el:order) if(!vis[el]) dfs2(el, true); forn(i, n) cn+=ans[i]; printf("%d\n", cn); forn(i, n) if(ans[i]) printf("%d ", i+1); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 74 ms | 47436 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 89 ms | 47500 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 10012 KB | Output is correct |
2 | Correct | 6 ms | 9940 KB | Output is correct |
3 | Correct | 7 ms | 9940 KB | Output is correct |
4 | Correct | 6 ms | 9976 KB | Output is correct |
5 | Correct | 6 ms | 9940 KB | Output is correct |
6 | Incorrect | 6 ms | 9892 KB | For each person outside the committee there should be someone in the committee who they dislike. |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 74 ms | 47436 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |