Submission #544672

# Submission time Handle Problem Language Result Execution time Memory
544672 2022-04-02T14:20:27 Z pokmui9909 None (KOI17_cat) C++17
100 / 100
328 ms 47640 KB
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
int N, M;
vector<int> G[300005];
int tn[300005], bn[300005];
int child[300005];
int cnt = 0;
 
void dfs(int n, int p, bool root)
{
    tn[n] = bn[n] = ++cnt;
    for(auto i : G[n])
    {
        if(i == p) continue;
        if(bn[i])
        {
            bn[n] = min(tn[i], bn[n]);
            continue;
        }
        dfs(i, n, 0);
        bn[n] = min(bn[i], bn[n]);
        if(tn[n] <= bn[i]) child[n]++;
    }
    if(root == 0) child[n]++;
}
 
int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
 
    cin >> N >> M;
    for(int i = 1; i <= M; i++)
    {
        int u, v; cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, -1, 1);
    ll ans = 0;
    for(int i = 1; i <= N; i++)
    {
        if(N - 1 == M - G[i].size() + child[i])
            ans += i;
    }
    cout << ans;
}

Compilation message

cat.cpp: In function 'int main()':
cat.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         if(N - 1 == M - G[i].size() + child[i])
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7292 KB Output is correct
5 Correct 9 ms 7716 KB Output is correct
6 Correct 8 ms 7652 KB Output is correct
7 Correct 5 ms 7900 KB Output is correct
8 Correct 5 ms 7636 KB Output is correct
9 Correct 8 ms 8028 KB Output is correct
10 Correct 8 ms 7764 KB Output is correct
11 Correct 8 ms 7904 KB Output is correct
12 Correct 6 ms 7892 KB Output is correct
13 Correct 6 ms 7764 KB Output is correct
14 Correct 5 ms 7764 KB Output is correct
15 Correct 5 ms 7376 KB Output is correct
16 Correct 4 ms 7392 KB Output is correct
17 Correct 4 ms 7380 KB Output is correct
18 Correct 6 ms 7380 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 6 ms 7908 KB Output is correct
21 Correct 7 ms 7904 KB Output is correct
22 Correct 7 ms 7892 KB Output is correct
23 Correct 5 ms 7648 KB Output is correct
24 Correct 5 ms 7588 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 202 ms 24524 KB Output is correct
2 Correct 192 ms 24380 KB Output is correct
3 Correct 243 ms 24392 KB Output is correct
4 Correct 197 ms 24492 KB Output is correct
5 Correct 185 ms 24388 KB Output is correct
6 Correct 190 ms 24456 KB Output is correct
7 Correct 206 ms 24468 KB Output is correct
8 Correct 202 ms 24436 KB Output is correct
9 Correct 210 ms 24552 KB Output is correct
10 Correct 202 ms 24568 KB Output is correct
11 Correct 213 ms 25024 KB Output is correct
12 Correct 191 ms 25016 KB Output is correct
13 Correct 202 ms 24916 KB Output is correct
14 Correct 200 ms 25112 KB Output is correct
15 Correct 192 ms 25080 KB Output is correct
16 Correct 191 ms 29488 KB Output is correct
17 Correct 199 ms 30596 KB Output is correct
18 Correct 196 ms 28452 KB Output is correct
19 Correct 195 ms 29512 KB Output is correct
20 Correct 221 ms 28528 KB Output is correct
21 Correct 225 ms 26832 KB Output is correct
22 Correct 216 ms 35640 KB Output is correct
23 Correct 207 ms 38476 KB Output is correct
24 Correct 253 ms 27168 KB Output is correct
25 Correct 253 ms 37384 KB Output is correct
26 Correct 119 ms 47544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 47536 KB Output is correct
2 Correct 124 ms 47596 KB Output is correct
3 Correct 101 ms 47540 KB Output is correct
4 Correct 109 ms 47640 KB Output is correct
5 Correct 110 ms 47568 KB Output is correct
6 Correct 127 ms 47528 KB Output is correct
7 Correct 109 ms 47616 KB Output is correct
8 Correct 116 ms 47516 KB Output is correct
9 Correct 114 ms 47532 KB Output is correct
10 Correct 166 ms 41816 KB Output is correct
11 Correct 145 ms 41880 KB Output is correct
12 Correct 132 ms 41768 KB Output is correct
13 Correct 127 ms 41808 KB Output is correct
14 Correct 131 ms 41932 KB Output is correct
15 Correct 139 ms 35820 KB Output is correct
16 Correct 153 ms 35780 KB Output is correct
17 Correct 121 ms 35876 KB Output is correct
18 Correct 147 ms 35984 KB Output is correct
19 Correct 125 ms 35920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7292 KB Output is correct
5 Correct 9 ms 7716 KB Output is correct
6 Correct 8 ms 7652 KB Output is correct
7 Correct 5 ms 7900 KB Output is correct
8 Correct 5 ms 7636 KB Output is correct
9 Correct 8 ms 8028 KB Output is correct
10 Correct 8 ms 7764 KB Output is correct
11 Correct 8 ms 7904 KB Output is correct
12 Correct 6 ms 7892 KB Output is correct
13 Correct 6 ms 7764 KB Output is correct
14 Correct 5 ms 7764 KB Output is correct
15 Correct 5 ms 7376 KB Output is correct
16 Correct 4 ms 7392 KB Output is correct
17 Correct 4 ms 7380 KB Output is correct
18 Correct 6 ms 7380 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 6 ms 7908 KB Output is correct
21 Correct 7 ms 7904 KB Output is correct
22 Correct 7 ms 7892 KB Output is correct
23 Correct 5 ms 7648 KB Output is correct
24 Correct 5 ms 7588 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct
26 Correct 202 ms 24524 KB Output is correct
27 Correct 192 ms 24380 KB Output is correct
28 Correct 243 ms 24392 KB Output is correct
29 Correct 197 ms 24492 KB Output is correct
30 Correct 185 ms 24388 KB Output is correct
31 Correct 190 ms 24456 KB Output is correct
32 Correct 206 ms 24468 KB Output is correct
33 Correct 202 ms 24436 KB Output is correct
34 Correct 210 ms 24552 KB Output is correct
35 Correct 202 ms 24568 KB Output is correct
36 Correct 213 ms 25024 KB Output is correct
37 Correct 191 ms 25016 KB Output is correct
38 Correct 202 ms 24916 KB Output is correct
39 Correct 200 ms 25112 KB Output is correct
40 Correct 192 ms 25080 KB Output is correct
41 Correct 191 ms 29488 KB Output is correct
42 Correct 199 ms 30596 KB Output is correct
43 Correct 196 ms 28452 KB Output is correct
44 Correct 195 ms 29512 KB Output is correct
45 Correct 221 ms 28528 KB Output is correct
46 Correct 225 ms 26832 KB Output is correct
47 Correct 216 ms 35640 KB Output is correct
48 Correct 207 ms 38476 KB Output is correct
49 Correct 253 ms 27168 KB Output is correct
50 Correct 253 ms 37384 KB Output is correct
51 Correct 119 ms 47544 KB Output is correct
52 Correct 111 ms 47536 KB Output is correct
53 Correct 124 ms 47596 KB Output is correct
54 Correct 101 ms 47540 KB Output is correct
55 Correct 109 ms 47640 KB Output is correct
56 Correct 110 ms 47568 KB Output is correct
57 Correct 127 ms 47528 KB Output is correct
58 Correct 109 ms 47616 KB Output is correct
59 Correct 116 ms 47516 KB Output is correct
60 Correct 114 ms 47532 KB Output is correct
61 Correct 166 ms 41816 KB Output is correct
62 Correct 145 ms 41880 KB Output is correct
63 Correct 132 ms 41768 KB Output is correct
64 Correct 127 ms 41808 KB Output is correct
65 Correct 131 ms 41932 KB Output is correct
66 Correct 139 ms 35820 KB Output is correct
67 Correct 153 ms 35780 KB Output is correct
68 Correct 121 ms 35876 KB Output is correct
69 Correct 147 ms 35984 KB Output is correct
70 Correct 125 ms 35920 KB Output is correct
71 Correct 271 ms 45972 KB Output is correct
72 Correct 306 ms 44148 KB Output is correct
73 Correct 303 ms 43384 KB Output is correct
74 Correct 328 ms 45348 KB Output is correct
75 Correct 287 ms 42004 KB Output is correct
76 Correct 286 ms 41716 KB Output is correct
77 Correct 305 ms 36904 KB Output is correct
78 Correct 311 ms 36528 KB Output is correct
79 Correct 300 ms 45736 KB Output is correct
80 Correct 306 ms 41540 KB Output is correct
81 Correct 281 ms 38312 KB Output is correct
82 Correct 296 ms 45520 KB Output is correct
83 Correct 325 ms 45708 KB Output is correct
84 Correct 308 ms 44196 KB Output is correct
85 Correct 310 ms 45120 KB Output is correct
86 Correct 225 ms 38396 KB Output is correct
87 Correct 212 ms 37776 KB Output is correct
88 Correct 162 ms 25116 KB Output is correct
89 Correct 178 ms 25440 KB Output is correct
90 Correct 158 ms 25420 KB Output is correct