# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56493 | red1108 | 산만한 고양이 (KOI17_cat) | C++17 | 542 ms | 263168 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |