Submission #101407

# Submission time Handle Problem Language Result Execution time Memory
101407 2019-03-19T01:07:07 Z rocketninja7 007 (CEOI14_007) C++14
30 / 100
408 ms 18152 KB
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
    int N, M, s, d, a, b;
    scanf("%d%d%d%d%d%d", &N, &M, &s, &d, &a, &b);
    vector<int> adjList[N+1];
    for(int i=0;i<M;i++){
        int u, v;
        scanf("%d%d", &u, &v);
        adjList[u].push_back(v);
        adjList[v].push_back(u);
    }
    queue<int> proc;
    proc.push(s);
    int dists[N+1];
    for(int i=1;i<N+1;i++){
        dists[i]=-1;
    }
    dists[s]=0;
    while(!proc.empty()){
        int node=proc.front();
        proc.pop();
        for(int i=0;i<adjList[node].size();i++){
            if(dists[adjList[node][i]]==-1){
                dists[adjList[node][i]]=dists[node]+1;
                proc.push(adjList[node][i]);
            }
        }
    }
    proc.push(d);
    int distd[N+1];
    for(int i=1;i<N+1;i++){
        distd[i]=-1;
    }
    distd[d]=0;
    while(!proc.empty()){
        int node=proc.front();
        proc.pop();
        for(int i=0;i<adjList[node].size();i++){
            if(distd[adjList[node][i]]==-1){
                distd[adjList[node][i]]=distd[node]+1;
                proc.push(adjList[node][i]);
            }
        }
    }
    printf("%d", max(min(distd[a]-dists[a], distd[b]-dists[b]), 0)-1);
    return 0;
}

Compilation message

007.cpp: In function 'int main()':
007.cpp:26:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<adjList[node].size();i++){
                     ~^~~~~~~~~~~~~~~~~~~~~
007.cpp:42:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<adjList[node].size();i++){
                     ~^~~~~~~~~~~~~~~~~~~~~
007.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d%d", &N, &M, &s, &d, &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 384 KB Partially correct
2 Partially correct 2 ms 256 KB Partially correct
3 Partially correct 2 ms 384 KB Partially correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Partially correct 2 ms 256 KB Partially correct
7 Partially correct 3 ms 276 KB Partially correct
8 Correct 2 ms 256 KB Output is correct
9 Partially correct 2 ms 384 KB Partially correct
10 Partially correct 2 ms 384 KB Partially correct
11 Partially correct 2 ms 256 KB Partially correct
12 Correct 2 ms 256 KB Output is correct
13 Partially correct 3 ms 384 KB Partially correct
14 Correct 2 ms 256 KB Output is correct
15 Partially correct 2 ms 256 KB Partially correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Partially correct 2 ms 384 KB Partially correct
20 Partially correct 2 ms 384 KB Partially correct
21 Partially correct 2 ms 384 KB Partially correct
22 Partially correct 2 ms 384 KB Partially correct
23 Partially correct 3 ms 384 KB Partially correct
24 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 28 ms 2860 KB Partially correct
2 Correct 47 ms 4140 KB Output is correct
3 Partially correct 27 ms 3008 KB Partially correct
4 Correct 35 ms 4188 KB Output is correct
5 Partially correct 25 ms 2696 KB Partially correct
6 Partially correct 24 ms 3192 KB Partially correct
7 Partially correct 28 ms 3328 KB Partially correct
8 Partially correct 32 ms 3320 KB Partially correct
9 Correct 51 ms 4820 KB Output is correct
10 Partially correct 197 ms 9744 KB Partially correct
11 Correct 65 ms 6008 KB Output is correct
12 Partially correct 95 ms 8028 KB Partially correct
13 Correct 59 ms 6364 KB Output is correct
14 Correct 47 ms 5412 KB Output is correct
15 Partially correct 80 ms 8312 KB Partially correct
16 Partially correct 107 ms 8696 KB Partially correct
17 Partially correct 89 ms 7672 KB Partially correct
18 Correct 96 ms 7772 KB Output is correct
19 Partially correct 123 ms 10104 KB Partially correct
20 Correct 226 ms 12712 KB Output is correct
21 Correct 112 ms 11688 KB Output is correct
22 Partially correct 112 ms 9976 KB Partially correct
23 Partially correct 129 ms 11440 KB Partially correct
24 Partially correct 122 ms 11256 KB Partially correct
25 Correct 107 ms 10744 KB Output is correct
26 Partially correct 108 ms 10112 KB Partially correct
27 Partially correct 125 ms 11564 KB Partially correct
28 Partially correct 118 ms 11516 KB Partially correct
29 Partially correct 154 ms 11788 KB Partially correct
30 Correct 250 ms 13732 KB Output is correct
31 Correct 145 ms 13144 KB Output is correct
32 Partially correct 139 ms 11512 KB Partially correct
33 Partially correct 147 ms 11804 KB Partially correct
34 Correct 137 ms 12260 KB Output is correct
35 Correct 134 ms 12024 KB Output is correct
36 Correct 170 ms 12536 KB Output is correct
37 Partially correct 149 ms 13788 KB Partially correct
38 Partially correct 194 ms 13432 KB Partially correct
39 Partially correct 175 ms 13548 KB Partially correct
40 Correct 253 ms 14856 KB Output is correct
41 Partially correct 408 ms 18152 KB Partially correct