Submission #101451

# Submission time Handle Problem Language Result Execution time Memory
101451 2019-03-19T02:28:33 Z dwsc 007 (CEOI14_007) C++14
6 / 100
627 ms 25424 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> adj[m];
    int s,d,a,b;
    cin >> s >> d >> a >> b;
    s--;
    d--;
    a--;
    b--;
    for (int i = 0; i < m; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    queue<int> q;
    int dist1[n],dist2[n];
    memset(dist1,-1,sizeof(dist1));
    memset(dist2,-1,sizeof(dist2));
    dist1[s] = 0;
    dist2[d] = 0;
    q.push(s);
    while (!q.empty()){
        int u = q.front();
        q.pop();
        for (int i = 0; i < adj[u].size(); i++){
            int v = adj[u][i];
            if (dist1[v] == -1){
                dist1[v] = dist1[u]+1;
                q.push(v);
            }
        }
    }
    q.push(d);
    while (!q.empty()){
        int u = q.front();
        q.pop();
        for (int i = 0; i < adj[u].size(); i++){
            int v = adj[u][i];
            if (dist2[v] == -1){
                dist2[v] = dist2[u]+1;
                q.push(v);
            }
        }
    }
   // cout << dist1[a] << " " << dist1[b] << "\n";
   // cout << dist2[a] << " " << dist2[b] << "\n";
    if (dist2[a] < dist1[a] && dist2[b] < dist1[b]) cout << -1;
    else cout << max(dist2[a]-dist1[a],dist2[b]-dist1[b])-1;
}

Compilation message

007.cpp: In function 'int main()':
007.cpp:31:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < adj[u].size(); i++){
                         ~~^~~~~~~~~~~~~~~
007.cpp:43:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < adj[u].size(); i++){
                         ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Partially correct 2 ms 256 KB Partially correct
3 Partially correct 3 ms 384 KB Partially correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Partially correct 3 ms 384 KB Partially correct
7 Partially correct 3 ms 256 KB Partially correct
8 Correct 2 ms 384 KB Output is correct
9 Partially correct 2 ms 384 KB Partially correct
10 Correct 3 ms 284 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Partially correct 3 ms 384 KB Partially correct
14 Correct 3 ms 256 KB Output is correct
15 Partially correct 2 ms 256 KB Partially correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Partially correct 3 ms 384 KB Partially correct
20 Partially correct 3 ms 384 KB Partially correct
21 Incorrect 3 ms 384 KB Output isn't correct
22 Partially correct 3 ms 384 KB Partially correct
23 Partially correct 2 ms 384 KB Partially correct
24 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 47 ms 2868 KB Partially correct
2 Correct 70 ms 4088 KB Output is correct
3 Partially correct 47 ms 3064 KB Partially correct
4 Correct 95 ms 4216 KB Output is correct
5 Incorrect 43 ms 2936 KB Output isn't correct
6 Incorrect 42 ms 3192 KB Output isn't correct
7 Partially correct 59 ms 3576 KB Partially correct
8 Partially correct 78 ms 3380 KB Partially correct
9 Correct 98 ms 4852 KB Output is correct
10 Partially correct 452 ms 17784 KB Partially correct
11 Correct 124 ms 6136 KB Output is correct
12 Partially correct 166 ms 7644 KB Partially correct
13 Correct 134 ms 6544 KB Output is correct
14 Correct 114 ms 5624 KB Output is correct
15 Partially correct 139 ms 7704 KB Partially correct
16 Incorrect 162 ms 8044 KB Output isn't correct
17 Partially correct 130 ms 7188 KB Partially correct
18 Correct 131 ms 7160 KB Output is correct
19 Partially correct 225 ms 10872 KB Partially correct
20 Correct 472 ms 19724 KB Output is correct
21 Correct 222 ms 10360 KB Output is correct
22 Partially correct 175 ms 9288 KB Partially correct
23 Partially correct 221 ms 10360 KB Partially correct
24 Partially correct 184 ms 10104 KB Partially correct
25 Correct 206 ms 9812 KB Output is correct
26 Partially correct 173 ms 9212 KB Partially correct
27 Partially correct 193 ms 10472 KB Partially correct
28 Partially correct 203 ms 10588 KB Partially correct
29 Partially correct 358 ms 13816 KB Partially correct
30 Correct 523 ms 20700 KB Output is correct
31 Correct 238 ms 11900 KB Output is correct
32 Partially correct 205 ms 10488 KB Partially correct
33 Partially correct 214 ms 10804 KB Partially correct
34 Correct 265 ms 11384 KB Output is correct
35 Correct 238 ms 10944 KB Output is correct
36 Correct 289 ms 11000 KB Output is correct
37 Incorrect 357 ms 12540 KB Output isn't correct
38 Partially correct 269 ms 12280 KB Partially correct
39 Partially correct 296 ms 12492 KB Partially correct
40 Correct 432 ms 17904 KB Output is correct
41 Partially correct 627 ms 25424 KB Partially correct