Submission #56493

#TimeUsernameProblemLanguageResultExecution timeMemory
56493red1108산만한 고양이 (KOI17_cat)C++17
45 / 100
542 ms263168 KiB
#include <stdio.h> #include <algorithm> #include <vector> typedef long long ll; using namespace std; vector<int> graph[300010]; int visit[300010], comp[300010],link[300010]; int n, m,vcnt; int dfs(int now, int from) { int cmp=1,ret,child=0; ret=visit[now]=++vcnt; for(auto i:graph[now]) { if(i==from) continue; if(!visit[i]) { int df; df=dfs(i,now); if(df>=visit[now]) cmp++; ret=min(ret,df); child++; } else ret=min(ret,visit[i]); } if(from==0) cmp=child; comp[now]=cmp; return ret; } int main() { scanf("%d %d", &n, &m); for(int i=1;i<=m;i++) { int a, b; scanf("%d %d", &a, &b); graph[a].push_back(b); graph[b].push_back(a); link[a]++,link[b]++; } dfs(1,0); ll ans=0; for(int i=1;i<=n;i++) { if(m-link[i]==n-comp[i]-1) ans+=i; } printf("%lld", ans); }

Compilation message (stderr)

cat.cpp: In function 'int main()':
cat.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
cat.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &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...