답안 #668539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668539 2022-12-04T05:23:41 Z RambaXGorilla 007 (CEOI14_007) C++17
0 / 100
220 ms 22284 KB
#include<cstdio>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
using namespace std;
typedef pair <int,int> ii;
int N, M, S, D, A, B;
vector <int> adj[200010];
queue <ii> near;
bool vis[200010] = {};
ii bfs(int X){
    ii servers;
    near.push(ii(X, 0));
    while(!near.empty()){
        int node = near.front().first;
        int dist = near.front().second;
        near.pop();
        if(vis[node]) continue;
        vis[node] = true;
        if(node == A) servers.first = dist;
        else if(node == B) servers.second = dist;
        for(int i : adj[node]){
            near.push(ii(i, dist + 1));
        }
    }
    fill(vis, vis + 200010, false);
    return servers;
}
int main(){
    scanf("%d%d%d%d%d%d",&N,&M,&S,&D,&A,&B);
    for(int i = 0;i < M;i++){
        int a, b;
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    ii agent = bfs(S);
    ii doctor = bfs(D);
    printf("%d",max(min(doctor.first - agent.first, doctor.second - agent.second), -1));
}

Compilation message

007.cpp: In function 'int main()':
007.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d%d%d%d%d%d",&N,&M,&S,&D,&A,&B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         scanf("%d%d",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 3 ms 5112 KB Output is correct
3 Correct 3 ms 5076 KB Output is correct
4 Incorrect 3 ms 5124 KB Output isn't correct
5 Incorrect 3 ms 5076 KB Output isn't correct
6 Correct 3 ms 5148 KB Output is correct
7 Correct 3 ms 5076 KB Output is correct
8 Incorrect 3 ms 5076 KB Output isn't correct
9 Correct 3 ms 5076 KB Output is correct
10 Correct 3 ms 5116 KB Output is correct
11 Correct 3 ms 5112 KB Output is correct
12 Incorrect 3 ms 5076 KB Output isn't correct
13 Correct 3 ms 5116 KB Output is correct
14 Incorrect 3 ms 5076 KB Output isn't correct
15 Correct 3 ms 5076 KB Output is correct
16 Incorrect 3 ms 5204 KB Output isn't correct
17 Incorrect 3 ms 5204 KB Output isn't correct
18 Incorrect 3 ms 5204 KB Output isn't correct
19 Correct 3 ms 5204 KB Output is correct
20 Correct 3 ms 5204 KB Output is correct
21 Correct 3 ms 5204 KB Output is correct
22 Correct 3 ms 5120 KB Output is correct
23 Correct 4 ms 5204 KB Output is correct
24 Incorrect 3 ms 5120 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 6916 KB Output is correct
2 Incorrect 26 ms 7708 KB Output isn't correct
3 Correct 19 ms 6996 KB Output is correct
4 Incorrect 24 ms 7688 KB Output isn't correct
5 Correct 19 ms 6828 KB Output is correct
6 Correct 20 ms 7040 KB Output is correct
7 Correct 20 ms 7252 KB Output is correct
8 Correct 20 ms 7252 KB Output is correct
9 Incorrect 32 ms 8076 KB Output isn't correct
10 Correct 137 ms 16512 KB Output is correct
11 Incorrect 43 ms 9100 KB Output isn't correct
12 Correct 49 ms 10124 KB Output is correct
13 Incorrect 40 ms 9344 KB Output isn't correct
14 Correct 33 ms 8712 KB Output is correct
15 Correct 49 ms 10112 KB Output is correct
16 Correct 51 ms 10444 KB Output is correct
17 Correct 44 ms 9784 KB Output is correct
18 Incorrect 47 ms 9908 KB Output isn't correct
19 Correct 82 ms 12164 KB Output is correct
20 Incorrect 161 ms 18140 KB Output isn't correct
21 Incorrect 69 ms 12108 KB Output isn't correct
22 Correct 60 ms 11124 KB Output is correct
23 Correct 72 ms 12068 KB Output is correct
24 Correct 65 ms 11900 KB Output is correct
25 Incorrect 64 ms 11560 KB Output isn't correct
26 Correct 62 ms 11212 KB Output is correct
27 Correct 69 ms 12120 KB Output is correct
28 Correct 69 ms 12164 KB Output is correct
29 Correct 116 ms 14220 KB Output is correct
30 Incorrect 175 ms 18864 KB Output isn't correct
31 Incorrect 80 ms 13188 KB Output isn't correct
32 Correct 69 ms 12148 KB Output is correct
33 Correct 75 ms 12312 KB Output is correct
34 Incorrect 79 ms 12908 KB Output isn't correct
35 Incorrect 70 ms 12296 KB Output isn't correct
36 Incorrect 71 ms 12660 KB Output isn't correct
37 Correct 89 ms 13620 KB Output is correct
38 Correct 84 ms 13472 KB Output is correct
39 Correct 87 ms 13628 KB Output is correct
40 Incorrect 157 ms 17228 KB Output isn't correct
41 Correct 220 ms 22284 KB Output is correct