Submission #788220

#TimeUsernameProblemLanguageResultExecution timeMemory
788220Username4132Povjerenstvo (COI22_povjerenstvo)C++14
13 / 100
211 ms73168 KiB
#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 yes[MAXN], vis[MAXN]; int n, m, ans; vector<int> g[MAXN]; void dfs(int v){ vis[v]=true; bool res=false; for(int to:g[v]){ if(!vis[to]) dfs(to); res|=yes[to]; } yes[v]=!res; } int main(){ scanf("%d %d", &n, &m); forn(i, m){ int a, b; scanf("%d %d", &a, &b); --a, --b; g[a].PB(b); } forn(i, n) if(!vis[i]) dfs(i); forn(i, n) ans+=yes[i]; printf("%d\n", ans); forn(i, n) if(yes[i]) printf("%d ", i+1); printf("\n"); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:25:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         int a, b; scanf("%d %d", &a, &b); --a, --b;
      |                   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...