Submission #789050

# Submission time Handle Problem Language Result Execution time Memory
789050 2023-07-20T22:21:02 Z Username4132 Povjerenstvo (COI22_povjerenstvo) C++14
13 / 100
387 ms 64172 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 = 500010;
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

Main.cpp: In function 'int main()':
Main.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:31:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         int a, b; scanf("%d %d", &a, &b); --a, --b;
      |                   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 162 ms 61808 KB Output is correct
2 Correct 162 ms 64172 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 51 ms 29880 KB Output is correct
5 Correct 103 ms 47324 KB Output is correct
6 Correct 149 ms 49900 KB Output is correct
7 Correct 121 ms 48660 KB Output is correct
8 Correct 153 ms 49520 KB Output is correct
9 Correct 309 ms 58324 KB Output is correct
10 Correct 216 ms 55560 KB Output is correct
11 Correct 290 ms 55412 KB Output is correct
12 Correct 298 ms 50880 KB Output is correct
13 Correct 215 ms 51552 KB Output is correct
14 Correct 211 ms 51676 KB Output is correct
15 Correct 200 ms 51744 KB Output is correct
16 Correct 196 ms 51936 KB Output is correct
17 Correct 54 ms 29004 KB Output is correct
18 Correct 92 ms 32884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 166 ms 61876 KB Output is correct
2 Correct 152 ms 50372 KB Output is correct
3 Correct 120 ms 47856 KB Output is correct
4 Correct 296 ms 54632 KB Output is correct
5 Incorrect 387 ms 55148 KB For each person outside the committee there should be someone in the committee who they dislike.
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 24080 KB Output is correct
2 Correct 13 ms 23956 KB Output is correct
3 Correct 12 ms 24020 KB Output is correct
4 Correct 13 ms 24020 KB Output is correct
5 Correct 13 ms 24000 KB Output is correct
6 Incorrect 13 ms 23980 KB For each person outside the committee there should be someone in the committee who they dislike.
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 162 ms 61808 KB Output is correct
2 Correct 162 ms 64172 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 51 ms 29880 KB Output is correct
5 Correct 103 ms 47324 KB Output is correct
6 Correct 149 ms 49900 KB Output is correct
7 Correct 121 ms 48660 KB Output is correct
8 Correct 153 ms 49520 KB Output is correct
9 Correct 309 ms 58324 KB Output is correct
10 Correct 216 ms 55560 KB Output is correct
11 Correct 290 ms 55412 KB Output is correct
12 Correct 298 ms 50880 KB Output is correct
13 Correct 215 ms 51552 KB Output is correct
14 Correct 211 ms 51676 KB Output is correct
15 Correct 200 ms 51744 KB Output is correct
16 Correct 196 ms 51936 KB Output is correct
17 Correct 54 ms 29004 KB Output is correct
18 Correct 92 ms 32884 KB Output is correct
19 Correct 166 ms 61876 KB Output is correct
20 Correct 152 ms 50372 KB Output is correct
21 Correct 120 ms 47856 KB Output is correct
22 Correct 296 ms 54632 KB Output is correct
23 Incorrect 387 ms 55148 KB For each person outside the committee there should be someone in the committee who they dislike.
24 Halted 0 ms 0 KB -