Submission #490309

# Submission time Handle Problem Language Result Execution time Memory
490309 2021-11-26T22:59:46 Z SirCovidThe19th 007 (CEOI14_007) C++17
0 / 100
406 ms 22724 KB
#include <bits/stdc++.h>
using namespace std;

const int mx = 2e5 + 5;

int n, m, s, v, a, b, ds[mx], dd[mx], da[mx], db[mx]; vector<int> adj[mx];

int bfs(int st, int en){
    queue<int> Q; int D[n + 1]; fill(D, D + n + 1, -1); 
    Q.push(st); D[st] = 0;
    while (!Q.empty()){
        int i = Q.front(); Q.pop();
        if (i == en) return D[i];
        for (int j : adj[i]) if (D[j] == -1) D[j] = D[i] + 1, Q.push(j);
    }
}

int main(){
    cin >> n >> m >> s >> v >> a >> b;
    for (int i = 1; i <= m; i++){
        int a, b; cin >> a >> b;
        adj[a].push_back(b); adj[b].push_back(a);
    }
    cout<<max(min(bfs(v, a) - bfs(s, a), bfs(v, b) - bfs(s, b)), -1)<<endl;
}

Compilation message

007.cpp: In function 'int bfs(int, int)':
007.cpp:9:16: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     queue<int> Q; int D[n + 1]; fill(D, D + n + 1, -1);
      |                ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Incorrect 2 ms 4940 KB Output isn't correct
5 Incorrect 2 ms 4940 KB Output isn't correct
6 Correct 2 ms 4940 KB Output is correct
7 Correct 2 ms 4940 KB Output is correct
8 Incorrect 3 ms 4940 KB Output isn't correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 2 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Incorrect 3 ms 4940 KB Output isn't correct
13 Correct 3 ms 5004 KB Output is correct
14 Incorrect 3 ms 4940 KB Output isn't correct
15 Correct 3 ms 5000 KB Output is correct
16 Incorrect 3 ms 4940 KB Output isn't correct
17 Incorrect 3 ms 5020 KB Output isn't correct
18 Incorrect 3 ms 4940 KB Output isn't correct
19 Correct 3 ms 4940 KB Output is correct
20 Correct 3 ms 4940 KB Output is correct
21 Correct 3 ms 4932 KB Output is correct
22 Correct 3 ms 4940 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Incorrect 3 ms 4940 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 6888 KB Output is correct
2 Incorrect 45 ms 7736 KB Output isn't correct
3 Correct 39 ms 7040 KB Output is correct
4 Incorrect 54 ms 7840 KB Output isn't correct
5 Correct 34 ms 6796 KB Output is correct
6 Correct 36 ms 7052 KB Output is correct
7 Correct 39 ms 7260 KB Output is correct
8 Correct 37 ms 7276 KB Output is correct
9 Incorrect 59 ms 8040 KB Output isn't correct
10 Correct 260 ms 16576 KB Output is correct
11 Incorrect 78 ms 9252 KB Output isn't correct
12 Correct 98 ms 10348 KB Output is correct
13 Incorrect 75 ms 9556 KB Output isn't correct
14 Correct 68 ms 8784 KB Output is correct
15 Correct 96 ms 10360 KB Output is correct
16 Correct 127 ms 10772 KB Output is correct
17 Correct 79 ms 10052 KB Output is correct
18 Incorrect 76 ms 10004 KB Output isn't correct
19 Correct 148 ms 12452 KB Output is correct
20 Incorrect 292 ms 18308 KB Output isn't correct
21 Incorrect 131 ms 12544 KB Output isn't correct
22 Correct 126 ms 11592 KB Output is correct
23 Correct 140 ms 12388 KB Output is correct
24 Correct 138 ms 12424 KB Output is correct
25 Incorrect 140 ms 12236 KB Output isn't correct
26 Correct 122 ms 11556 KB Output is correct
27 Correct 122 ms 12552 KB Output is correct
28 Correct 123 ms 12536 KB Output is correct
29 Correct 191 ms 14636 KB Output is correct
30 Incorrect 313 ms 19164 KB Output isn't correct
31 Incorrect 160 ms 13720 KB Output isn't correct
32 Correct 150 ms 12476 KB Output is correct
33 Correct 161 ms 12920 KB Output is correct
34 Incorrect 162 ms 13216 KB Output isn't correct
35 Incorrect 139 ms 12852 KB Output isn't correct
36 Incorrect 139 ms 13140 KB Output isn't correct
37 Correct 194 ms 14392 KB Output is correct
38 Correct 153 ms 14020 KB Output is correct
39 Correct 162 ms 14104 KB Output is correct
40 Incorrect 257 ms 17704 KB Output isn't correct
41 Correct 406 ms 22724 KB Output is correct