답안 #65024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65024 2018-08-06T12:59:58 Z bazsi700 007 (CEOI14_007) C++14
0 / 100
356 ms 15980 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,s,d,a,b;
    cin >> n >> m >> s >> d >> a >> b;
    vector<vector<int> > graph(n+1,vector<int>());
    for(int i = 0; i < m; i++) {
        int x,y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    vector<bool> wass(n+1,false);
    vector<int> dists(n+1,0);
    vector<bool> wasd(n+1,false);
    vector<int> distd(n+1,0);
    wass[s] = true;
    queue<int> q;
    q.push(s);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for(int u : graph[v]) {
            if(!wass[u]) {
                wass[u] = true;
                q.push(u);
                dists[u] = dists[v]+1;
            }
        }
    }
    wasd[d] = true;
    q.push(d);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for(int u : graph[v]) {
            if(!wasd[u]) {
                wasd[u] = true;
                q.push(u);
                distd[u] = distd[v]+1;
            }
        }
    }
    cout << max(min(distd[a]-dists[a],distd[b]-dists[b]),-1);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 452 KB Output is correct
3 Correct 3 ms 532 KB Output is correct
4 Incorrect 3 ms 532 KB Output isn't correct
5 Incorrect 4 ms 636 KB Output isn't correct
6 Correct 1 ms 660 KB Output is correct
7 Correct 3 ms 660 KB Output is correct
8 Incorrect 2 ms 660 KB Output isn't correct
9 Correct 4 ms 660 KB Output is correct
10 Correct 4 ms 660 KB Output is correct
11 Correct 3 ms 660 KB Output is correct
12 Incorrect 4 ms 660 KB Output isn't correct
13 Correct 3 ms 660 KB Output is correct
14 Incorrect 3 ms 660 KB Output isn't correct
15 Correct 3 ms 660 KB Output is correct
16 Incorrect 3 ms 660 KB Output isn't correct
17 Incorrect 3 ms 724 KB Output isn't correct
18 Incorrect 3 ms 724 KB Output isn't correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 760 KB Output is correct
21 Correct 2 ms 760 KB Output is correct
22 Correct 4 ms 760 KB Output is correct
23 Correct 4 ms 760 KB Output is correct
24 Incorrect 5 ms 760 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 3180 KB Output is correct
2 Incorrect 58 ms 4452 KB Output isn't correct
3 Correct 34 ms 4452 KB Output is correct
4 Incorrect 79 ms 4460 KB Output isn't correct
5 Correct 42 ms 4460 KB Output is correct
6 Correct 45 ms 4460 KB Output is correct
7 Correct 36 ms 4460 KB Output is correct
8 Correct 48 ms 4460 KB Output is correct
9 Incorrect 74 ms 4460 KB Output isn't correct
10 Correct 252 ms 8684 KB Output is correct
11 Incorrect 108 ms 8684 KB Output isn't correct
12 Correct 145 ms 8684 KB Output is correct
13 Incorrect 90 ms 8684 KB Output isn't correct
14 Correct 72 ms 8684 KB Output is correct
15 Correct 102 ms 8684 KB Output is correct
16 Correct 140 ms 8684 KB Output is correct
17 Correct 131 ms 8684 KB Output is correct
18 Incorrect 106 ms 8684 KB Output isn't correct
19 Correct 156 ms 8684 KB Output is correct
20 Incorrect 309 ms 11632 KB Output isn't correct
21 Incorrect 195 ms 11632 KB Output isn't correct
22 Correct 147 ms 11632 KB Output is correct
23 Correct 127 ms 11632 KB Output is correct
24 Correct 179 ms 11632 KB Output is correct
25 Incorrect 178 ms 11632 KB Output isn't correct
26 Correct 148 ms 11632 KB Output is correct
27 Correct 219 ms 11632 KB Output is correct
28 Correct 219 ms 11632 KB Output is correct
29 Correct 245 ms 11632 KB Output is correct
30 Incorrect 328 ms 12700 KB Output isn't correct
31 Incorrect 186 ms 12700 KB Output isn't correct
32 Correct 153 ms 12700 KB Output is correct
33 Correct 142 ms 12700 KB Output is correct
34 Incorrect 174 ms 12700 KB Output isn't correct
35 Incorrect 173 ms 12700 KB Output isn't correct
36 Incorrect 229 ms 12700 KB Output isn't correct
37 Correct 209 ms 12804 KB Output is correct
38 Correct 238 ms 12804 KB Output is correct
39 Correct 210 ms 12804 KB Output is correct
40 Incorrect 280 ms 14060 KB Output isn't correct
41 Correct 356 ms 15980 KB Output is correct