Submission #345454

# Submission time Handle Problem Language Result Execution time Memory
345454 2021-01-07T11:10:19 Z impri None (KOI17_cat) C++14
100 / 100
532 ms 50048 KB
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int>graph[300001];
int num[300001];
int low[300001];
int visited[300001];
int parent[300001];
int res[300001];
int cnt=1;
int rnum=0;
void v(int c){
num[c]=cnt;
low[c]=cnt;
visited[c]=1;
cnt++;
for(int i=0;i<graph[c].size();i++){
    int nxt=graph[c][i];
    if(!visited[nxt]){
       if(c==1)
        rnum++;
        parent[nxt]=c;
        v(nxt);
        if(low[nxt]>=num[c]){
            res[c]++;
        }
        low[c]=min(low[nxt], low[c]);
    }
    else{
        if(nxt!=parent[c]){
            low[c]=min(num[nxt],low[c]);
        }
    }
}


}
int main(void){
cin >> n >> m;
for(int i=2;i<=n;i++)res[i]=1;
for(int i=1;i<=m;i++){
    int a,b;
    cin >> a >> b;
   graph[b].push_back(a); graph[a].push_back(b);
}
v(1);
long long result=0;
if(m-graph[1].size()==n-1-rnum)result+=1;
for(int i=2;i<=n;i++){
    if(m-graph[i].size()==n-1-res[i])result+=i;
}
cout << result;
}

Compilation message

cat.cpp: In function 'void v(int)':
cat.cpp:17:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 | for(int i=0;i<graph[c].size();i++){
      |             ~^~~~~~~~~~~~~~~~
cat.cpp:20:8: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   20 |        if(c==1)
      |        ^~
cat.cpp:22:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   22 |         parent[nxt]=c;
      |         ^~~~~~
cat.cpp: In function 'int main()':
cat.cpp:48:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 | if(m-graph[1].size()==n-1-rnum)result+=1;
      |    ~~~~~~~~~~~~~~~~~^~~~~~~~~~
cat.cpp:50:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |     if(m-graph[i].size()==n-1-res[i])result+=i;
      |        ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 6 ms 7404 KB Output is correct
4 Correct 6 ms 7532 KB Output is correct
5 Correct 12 ms 7820 KB Output is correct
6 Correct 10 ms 7772 KB Output is correct
7 Correct 10 ms 7920 KB Output is correct
8 Correct 11 ms 7788 KB Output is correct
9 Correct 10 ms 8044 KB Output is correct
10 Correct 11 ms 7916 KB Output is correct
11 Correct 11 ms 8044 KB Output is correct
12 Correct 9 ms 8044 KB Output is correct
13 Correct 9 ms 7788 KB Output is correct
14 Correct 9 ms 7788 KB Output is correct
15 Correct 6 ms 7404 KB Output is correct
16 Correct 6 ms 7404 KB Output is correct
17 Correct 7 ms 7404 KB Output is correct
18 Correct 6 ms 7404 KB Output is correct
19 Correct 6 ms 7540 KB Output is correct
20 Correct 11 ms 8064 KB Output is correct
21 Correct 12 ms 8044 KB Output is correct
22 Correct 12 ms 8044 KB Output is correct
23 Correct 10 ms 7660 KB Output is correct
24 Correct 11 ms 7660 KB Output is correct
25 Correct 6 ms 7404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 532 ms 26848 KB Output is correct
2 Correct 443 ms 26860 KB Output is correct
3 Correct 482 ms 26400 KB Output is correct
4 Correct 453 ms 26856 KB Output is correct
5 Correct 425 ms 26604 KB Output is correct
6 Correct 458 ms 26880 KB Output is correct
7 Correct 469 ms 26860 KB Output is correct
8 Correct 432 ms 26388 KB Output is correct
9 Correct 423 ms 27072 KB Output is correct
10 Correct 440 ms 27016 KB Output is correct
11 Correct 417 ms 27372 KB Output is correct
12 Correct 460 ms 27404 KB Output is correct
13 Correct 430 ms 27032 KB Output is correct
14 Correct 436 ms 27452 KB Output is correct
15 Correct 467 ms 27432 KB Output is correct
16 Correct 417 ms 32008 KB Output is correct
17 Correct 438 ms 32620 KB Output is correct
18 Correct 464 ms 30876 KB Output is correct
19 Correct 427 ms 31596 KB Output is correct
20 Correct 428 ms 31072 KB Output is correct
21 Correct 456 ms 29240 KB Output is correct
22 Correct 416 ms 38016 KB Output is correct
23 Correct 400 ms 40640 KB Output is correct
24 Correct 469 ms 29584 KB Output is correct
25 Correct 404 ms 39880 KB Output is correct
26 Correct 274 ms 50028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 274 ms 50048 KB Output is correct
2 Correct 278 ms 50028 KB Output is correct
3 Correct 269 ms 50028 KB Output is correct
4 Correct 270 ms 49792 KB Output is correct
5 Correct 279 ms 49976 KB Output is correct
6 Correct 257 ms 49924 KB Output is correct
7 Correct 276 ms 49968 KB Output is correct
8 Correct 260 ms 49996 KB Output is correct
9 Correct 286 ms 49868 KB Output is correct
10 Correct 286 ms 43788 KB Output is correct
11 Correct 277 ms 43816 KB Output is correct
12 Correct 271 ms 43788 KB Output is correct
13 Correct 274 ms 43912 KB Output is correct
14 Correct 274 ms 43624 KB Output is correct
15 Correct 276 ms 37360 KB Output is correct
16 Correct 304 ms 36996 KB Output is correct
17 Correct 281 ms 37092 KB Output is correct
18 Correct 285 ms 37276 KB Output is correct
19 Correct 278 ms 37348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 6 ms 7404 KB Output is correct
4 Correct 6 ms 7532 KB Output is correct
5 Correct 12 ms 7820 KB Output is correct
6 Correct 10 ms 7772 KB Output is correct
7 Correct 10 ms 7920 KB Output is correct
8 Correct 11 ms 7788 KB Output is correct
9 Correct 10 ms 8044 KB Output is correct
10 Correct 11 ms 7916 KB Output is correct
11 Correct 11 ms 8044 KB Output is correct
12 Correct 9 ms 8044 KB Output is correct
13 Correct 9 ms 7788 KB Output is correct
14 Correct 9 ms 7788 KB Output is correct
15 Correct 6 ms 7404 KB Output is correct
16 Correct 6 ms 7404 KB Output is correct
17 Correct 7 ms 7404 KB Output is correct
18 Correct 6 ms 7404 KB Output is correct
19 Correct 6 ms 7540 KB Output is correct
20 Correct 11 ms 8064 KB Output is correct
21 Correct 12 ms 8044 KB Output is correct
22 Correct 12 ms 8044 KB Output is correct
23 Correct 10 ms 7660 KB Output is correct
24 Correct 11 ms 7660 KB Output is correct
25 Correct 6 ms 7404 KB Output is correct
26 Correct 532 ms 26848 KB Output is correct
27 Correct 443 ms 26860 KB Output is correct
28 Correct 482 ms 26400 KB Output is correct
29 Correct 453 ms 26856 KB Output is correct
30 Correct 425 ms 26604 KB Output is correct
31 Correct 458 ms 26880 KB Output is correct
32 Correct 469 ms 26860 KB Output is correct
33 Correct 432 ms 26388 KB Output is correct
34 Correct 423 ms 27072 KB Output is correct
35 Correct 440 ms 27016 KB Output is correct
36 Correct 417 ms 27372 KB Output is correct
37 Correct 460 ms 27404 KB Output is correct
38 Correct 430 ms 27032 KB Output is correct
39 Correct 436 ms 27452 KB Output is correct
40 Correct 467 ms 27432 KB Output is correct
41 Correct 417 ms 32008 KB Output is correct
42 Correct 438 ms 32620 KB Output is correct
43 Correct 464 ms 30876 KB Output is correct
44 Correct 427 ms 31596 KB Output is correct
45 Correct 428 ms 31072 KB Output is correct
46 Correct 456 ms 29240 KB Output is correct
47 Correct 416 ms 38016 KB Output is correct
48 Correct 400 ms 40640 KB Output is correct
49 Correct 469 ms 29584 KB Output is correct
50 Correct 404 ms 39880 KB Output is correct
51 Correct 274 ms 50028 KB Output is correct
52 Correct 274 ms 50048 KB Output is correct
53 Correct 278 ms 50028 KB Output is correct
54 Correct 269 ms 50028 KB Output is correct
55 Correct 270 ms 49792 KB Output is correct
56 Correct 279 ms 49976 KB Output is correct
57 Correct 257 ms 49924 KB Output is correct
58 Correct 276 ms 49968 KB Output is correct
59 Correct 260 ms 49996 KB Output is correct
60 Correct 286 ms 49868 KB Output is correct
61 Correct 286 ms 43788 KB Output is correct
62 Correct 277 ms 43816 KB Output is correct
63 Correct 271 ms 43788 KB Output is correct
64 Correct 274 ms 43912 KB Output is correct
65 Correct 274 ms 43624 KB Output is correct
66 Correct 276 ms 37360 KB Output is correct
67 Correct 304 ms 36996 KB Output is correct
68 Correct 281 ms 37092 KB Output is correct
69 Correct 285 ms 37276 KB Output is correct
70 Correct 278 ms 37348 KB Output is correct
71 Correct 508 ms 48364 KB Output is correct
72 Correct 475 ms 46572 KB Output is correct
73 Correct 465 ms 45700 KB Output is correct
74 Correct 485 ms 47860 KB Output is correct
75 Correct 475 ms 44544 KB Output is correct
76 Correct 507 ms 44188 KB Output is correct
77 Correct 478 ms 39344 KB Output is correct
78 Correct 485 ms 38940 KB Output is correct
79 Correct 493 ms 48364 KB Output is correct
80 Correct 509 ms 44088 KB Output is correct
81 Correct 484 ms 40724 KB Output is correct
82 Correct 499 ms 48040 KB Output is correct
83 Correct 506 ms 48108 KB Output is correct
84 Correct 485 ms 46700 KB Output is correct
85 Correct 498 ms 47536 KB Output is correct
86 Correct 367 ms 40696 KB Output is correct
87 Correct 359 ms 40072 KB Output is correct
88 Correct 301 ms 27484 KB Output is correct
89 Correct 313 ms 27868 KB Output is correct
90 Correct 305 ms 27904 KB Output is correct