답안 #345433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
345433 2021-01-07T10:09:49 Z impri 산만한 고양이 (KOI17_cat) C++14
33 / 100
497 ms 50108 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(low[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;
      |        ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Incorrect 6 ms 7404 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 485 ms 26948 KB Output is correct
2 Correct 408 ms 26860 KB Output is correct
3 Correct 491 ms 26852 KB Output is correct
4 Correct 448 ms 26932 KB Output is correct
5 Correct 487 ms 26860 KB Output is correct
6 Correct 425 ms 27000 KB Output is correct
7 Correct 450 ms 26988 KB Output is correct
8 Correct 430 ms 26948 KB Output is correct
9 Correct 416 ms 26968 KB Output is correct
10 Correct 440 ms 26996 KB Output is correct
11 Correct 448 ms 27400 KB Output is correct
12 Correct 434 ms 27556 KB Output is correct
13 Correct 424 ms 27396 KB Output is correct
14 Correct 454 ms 27528 KB Output is correct
15 Correct 425 ms 27500 KB Output is correct
16 Correct 439 ms 31852 KB Output is correct
17 Correct 497 ms 33004 KB Output is correct
18 Correct 416 ms 30828 KB Output is correct
19 Correct 423 ms 31896 KB Output is correct
20 Correct 435 ms 31044 KB Output is correct
21 Correct 445 ms 29420 KB Output is correct
22 Correct 413 ms 38164 KB Output is correct
23 Correct 403 ms 40828 KB Output is correct
24 Correct 429 ms 29676 KB Output is correct
25 Correct 399 ms 39916 KB Output is correct
26 Correct 268 ms 50028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 254 ms 50028 KB Output is correct
2 Correct 255 ms 50020 KB Output is correct
3 Correct 258 ms 50096 KB Output is correct
4 Correct 257 ms 50000 KB Output is correct
5 Correct 267 ms 49992 KB Output is correct
6 Correct 272 ms 50036 KB Output is correct
7 Correct 330 ms 50108 KB Output is correct
8 Correct 311 ms 50048 KB Output is correct
9 Correct 307 ms 50028 KB Output is correct
10 Correct 316 ms 44008 KB Output is correct
11 Correct 269 ms 43880 KB Output is correct
12 Correct 275 ms 43908 KB Output is correct
13 Correct 296 ms 43908 KB Output is correct
14 Correct 338 ms 43880 KB Output is correct
15 Correct 309 ms 37616 KB Output is correct
16 Correct 315 ms 37436 KB Output is correct
17 Correct 314 ms 37616 KB Output is correct
18 Correct 363 ms 37476 KB Output is correct
19 Correct 342 ms 37604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Incorrect 6 ms 7404 KB Output isn't correct
4 Halted 0 ms 0 KB -