답안 #56495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56495 2018-07-11T13:27:56 Z red1108 산만한 고양이 (KOI17_cat) C++17
100 / 100
462 ms 53796 KB
#include <stdio.h>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;
vector<int> graph[300010];
int visit[300010],comp[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);
    }
    dfs(1,0);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(m-graph[i].size()==n-comp[i]-1) ans+=i;
    }
    printf("%lld", ans);
}

Compilation message

cat.cpp: In function 'int main()':
cat.cpp:44:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(m-graph[i].size()==n-comp[i]-1) ans+=i;
            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
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);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Correct 11 ms 7532 KB Output is correct
3 Correct 10 ms 7532 KB Output is correct
4 Correct 10 ms 7620 KB Output is correct
5 Correct 15 ms 7944 KB Output is correct
6 Correct 12 ms 7944 KB Output is correct
7 Correct 13 ms 8368 KB Output is correct
8 Correct 13 ms 8368 KB Output is correct
9 Correct 13 ms 8380 KB Output is correct
10 Correct 12 ms 8380 KB Output is correct
11 Correct 12 ms 8476 KB Output is correct
12 Correct 12 ms 8524 KB Output is correct
13 Correct 10 ms 8524 KB Output is correct
14 Correct 10 ms 8524 KB Output is correct
15 Correct 8 ms 8524 KB Output is correct
16 Correct 7 ms 8524 KB Output is correct
17 Correct 9 ms 8524 KB Output is correct
18 Correct 9 ms 8524 KB Output is correct
19 Correct 9 ms 8524 KB Output is correct
20 Correct 14 ms 8704 KB Output is correct
21 Correct 11 ms 8752 KB Output is correct
22 Correct 11 ms 8800 KB Output is correct
23 Correct 11 ms 8800 KB Output is correct
24 Correct 9 ms 8800 KB Output is correct
25 Correct 9 ms 8800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 20840 KB Output is correct
2 Correct 310 ms 20936 KB Output is correct
3 Correct 301 ms 20936 KB Output is correct
4 Correct 288 ms 20936 KB Output is correct
5 Correct 300 ms 20936 KB Output is correct
6 Correct 372 ms 20960 KB Output is correct
7 Correct 325 ms 20960 KB Output is correct
8 Correct 378 ms 20960 KB Output is correct
9 Correct 390 ms 21112 KB Output is correct
10 Correct 350 ms 21112 KB Output is correct
11 Correct 356 ms 21448 KB Output is correct
12 Correct 350 ms 21480 KB Output is correct
13 Correct 363 ms 21480 KB Output is correct
14 Correct 360 ms 21540 KB Output is correct
15 Correct 306 ms 21540 KB Output is correct
16 Correct 362 ms 25752 KB Output is correct
17 Correct 325 ms 27208 KB Output is correct
18 Correct 293 ms 27208 KB Output is correct
19 Correct 359 ms 27208 KB Output is correct
20 Correct 374 ms 27208 KB Output is correct
21 Correct 321 ms 27208 KB Output is correct
22 Correct 386 ms 32088 KB Output is correct
23 Correct 371 ms 34760 KB Output is correct
24 Correct 405 ms 34760 KB Output is correct
25 Correct 362 ms 34760 KB Output is correct
26 Correct 165 ms 43976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 176 ms 44016 KB Output is correct
2 Correct 176 ms 44016 KB Output is correct
3 Correct 169 ms 44016 KB Output is correct
4 Correct 139 ms 44016 KB Output is correct
5 Correct 141 ms 44016 KB Output is correct
6 Correct 144 ms 44016 KB Output is correct
7 Correct 141 ms 44016 KB Output is correct
8 Correct 139 ms 44016 KB Output is correct
9 Correct 167 ms 44016 KB Output is correct
10 Correct 199 ms 44016 KB Output is correct
11 Correct 166 ms 44016 KB Output is correct
12 Correct 213 ms 44016 KB Output is correct
13 Correct 221 ms 44016 KB Output is correct
14 Correct 184 ms 44016 KB Output is correct
15 Correct 167 ms 44016 KB Output is correct
16 Correct 184 ms 44016 KB Output is correct
17 Correct 271 ms 44016 KB Output is correct
18 Correct 212 ms 44016 KB Output is correct
19 Correct 338 ms 44016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 7416 KB Output is correct
2 Correct 11 ms 7532 KB Output is correct
3 Correct 10 ms 7532 KB Output is correct
4 Correct 10 ms 7620 KB Output is correct
5 Correct 15 ms 7944 KB Output is correct
6 Correct 12 ms 7944 KB Output is correct
7 Correct 13 ms 8368 KB Output is correct
8 Correct 13 ms 8368 KB Output is correct
9 Correct 13 ms 8380 KB Output is correct
10 Correct 12 ms 8380 KB Output is correct
11 Correct 12 ms 8476 KB Output is correct
12 Correct 12 ms 8524 KB Output is correct
13 Correct 10 ms 8524 KB Output is correct
14 Correct 10 ms 8524 KB Output is correct
15 Correct 8 ms 8524 KB Output is correct
16 Correct 7 ms 8524 KB Output is correct
17 Correct 9 ms 8524 KB Output is correct
18 Correct 9 ms 8524 KB Output is correct
19 Correct 9 ms 8524 KB Output is correct
20 Correct 14 ms 8704 KB Output is correct
21 Correct 11 ms 8752 KB Output is correct
22 Correct 11 ms 8800 KB Output is correct
23 Correct 11 ms 8800 KB Output is correct
24 Correct 9 ms 8800 KB Output is correct
25 Correct 9 ms 8800 KB Output is correct
26 Correct 303 ms 20840 KB Output is correct
27 Correct 310 ms 20936 KB Output is correct
28 Correct 301 ms 20936 KB Output is correct
29 Correct 288 ms 20936 KB Output is correct
30 Correct 300 ms 20936 KB Output is correct
31 Correct 372 ms 20960 KB Output is correct
32 Correct 325 ms 20960 KB Output is correct
33 Correct 378 ms 20960 KB Output is correct
34 Correct 390 ms 21112 KB Output is correct
35 Correct 350 ms 21112 KB Output is correct
36 Correct 356 ms 21448 KB Output is correct
37 Correct 350 ms 21480 KB Output is correct
38 Correct 363 ms 21480 KB Output is correct
39 Correct 360 ms 21540 KB Output is correct
40 Correct 306 ms 21540 KB Output is correct
41 Correct 362 ms 25752 KB Output is correct
42 Correct 325 ms 27208 KB Output is correct
43 Correct 293 ms 27208 KB Output is correct
44 Correct 359 ms 27208 KB Output is correct
45 Correct 374 ms 27208 KB Output is correct
46 Correct 321 ms 27208 KB Output is correct
47 Correct 386 ms 32088 KB Output is correct
48 Correct 371 ms 34760 KB Output is correct
49 Correct 405 ms 34760 KB Output is correct
50 Correct 362 ms 34760 KB Output is correct
51 Correct 165 ms 43976 KB Output is correct
52 Correct 176 ms 44016 KB Output is correct
53 Correct 176 ms 44016 KB Output is correct
54 Correct 169 ms 44016 KB Output is correct
55 Correct 139 ms 44016 KB Output is correct
56 Correct 141 ms 44016 KB Output is correct
57 Correct 144 ms 44016 KB Output is correct
58 Correct 141 ms 44016 KB Output is correct
59 Correct 139 ms 44016 KB Output is correct
60 Correct 167 ms 44016 KB Output is correct
61 Correct 199 ms 44016 KB Output is correct
62 Correct 166 ms 44016 KB Output is correct
63 Correct 213 ms 44016 KB Output is correct
64 Correct 221 ms 44016 KB Output is correct
65 Correct 184 ms 44016 KB Output is correct
66 Correct 167 ms 44016 KB Output is correct
67 Correct 184 ms 44016 KB Output is correct
68 Correct 271 ms 44016 KB Output is correct
69 Correct 212 ms 44016 KB Output is correct
70 Correct 338 ms 44016 KB Output is correct
71 Correct 460 ms 44016 KB Output is correct
72 Correct 456 ms 44016 KB Output is correct
73 Correct 456 ms 44016 KB Output is correct
74 Correct 437 ms 44016 KB Output is correct
75 Correct 453 ms 44016 KB Output is correct
76 Correct 435 ms 44016 KB Output is correct
77 Correct 337 ms 44016 KB Output is correct
78 Correct 438 ms 44016 KB Output is correct
79 Correct 457 ms 44016 KB Output is correct
80 Correct 459 ms 44016 KB Output is correct
81 Correct 439 ms 44016 KB Output is correct
82 Correct 462 ms 44016 KB Output is correct
83 Correct 387 ms 46020 KB Output is correct
84 Correct 421 ms 48568 KB Output is correct
85 Correct 449 ms 53388 KB Output is correct
86 Correct 359 ms 53388 KB Output is correct
87 Correct 303 ms 53796 KB Output is correct
88 Correct 291 ms 53796 KB Output is correct
89 Correct 237 ms 53796 KB Output is correct
90 Correct 288 ms 53796 KB Output is correct