답안 #117060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
117060 2019-06-14T14:34:35 Z JohnTitor 007 (CEOI14_007) C++11
0 / 100
81 ms 12668 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
#define taskname "007"
int n, m;
int s, d, a, b;
int sa, sb, da, db;
int wa, wb;
int fa[200001];
bool donea[200001];
int fb[200001];
bool doneb[200001];
vector <int> g[200001];
queue <int> q;
void bfs(int s, int *f, bool *done){
    FOR(i, 1, n) done[i]=0;
    f[s]=0;
    done[s]=1;
    q.push(s);
    while(!q.empty()){
        s=q.front();
        q.pop();
        for(int v: g[s]) if(!done[v]){
            done[v]=1;
            f[v]=f[s]+1;
            q.push(v);
        }
    }
}
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    read(n);
    read(m);
    read(s);
    read(d);
    read(a);
    read(b);
    {
        int u, v;
        FOR(i, 1, m){
            read(u);
            read(v);
        }
    }
    bfs(a, fa, donea);
    bfs(b, fb, doneb);
    sa=fa[s];
    da=fa[d];
    sb=fb[s];
    db=fb[d];
    wa=sa-da;
    wb=sb-db;
    if(wa<0||wb<0){
        puts("-1");
        return 0;
    }
    else if(wa!=wb){
        writeln(min(wa, wb));
    }
    else{
        writeln(wa-1);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 6 ms 4992 KB Partially correct
2 Incorrect 6 ms 5120 KB Output isn't correct
3 Partially correct 6 ms 5072 KB Partially correct
4 Partially correct 6 ms 4992 KB Partially correct
5 Partially correct 6 ms 5120 KB Partially correct
6 Incorrect 7 ms 5028 KB Output isn't correct
7 Incorrect 6 ms 5120 KB Output isn't correct
8 Partially correct 6 ms 5120 KB Partially correct
9 Incorrect 7 ms 5120 KB Output isn't correct
10 Incorrect 6 ms 5108 KB Output isn't correct
11 Incorrect 6 ms 5120 KB Output isn't correct
12 Incorrect 6 ms 5120 KB Output isn't correct
13 Incorrect 6 ms 4992 KB Output isn't correct
14 Incorrect 6 ms 5120 KB Output isn't correct
15 Incorrect 6 ms 5120 KB Output isn't correct
16 Incorrect 6 ms 5120 KB Output isn't correct
17 Incorrect 6 ms 5120 KB Output isn't correct
18 Incorrect 6 ms 5120 KB Output isn't correct
19 Incorrect 7 ms 5120 KB Output isn't correct
20 Incorrect 6 ms 4992 KB Output isn't correct
21 Incorrect 6 ms 5120 KB Output isn't correct
22 Incorrect 6 ms 5120 KB Output isn't correct
23 Incorrect 6 ms 5120 KB Output isn't correct
24 Partially correct 6 ms 5120 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 5632 KB Output isn't correct
2 Incorrect 12 ms 5888 KB Output isn't correct
3 Incorrect 11 ms 5624 KB Output isn't correct
4 Incorrect 14 ms 5888 KB Output isn't correct
5 Incorrect 15 ms 5708 KB Output isn't correct
6 Incorrect 11 ms 5632 KB Output isn't correct
7 Incorrect 11 ms 5632 KB Output isn't correct
8 Incorrect 11 ms 5760 KB Output isn't correct
9 Incorrect 15 ms 6144 KB Output isn't correct
10 Incorrect 51 ms 10376 KB Output isn't correct
11 Incorrect 20 ms 6516 KB Output isn't correct
12 Incorrect 19 ms 6784 KB Output isn't correct
13 Incorrect 22 ms 6400 KB Output isn't correct
14 Correct 15 ms 6144 KB Output is correct
15 Incorrect 17 ms 6768 KB Output isn't correct
16 Incorrect 18 ms 6784 KB Output isn't correct
17 Incorrect 16 ms 6528 KB Output isn't correct
18 Incorrect 19 ms 6528 KB Output isn't correct
19 Incorrect 30 ms 7800 KB Output isn't correct
20 Incorrect 48 ms 10744 KB Output isn't correct
21 Incorrect 22 ms 7424 KB Output isn't correct
22 Incorrect 20 ms 7032 KB Output isn't correct
23 Incorrect 22 ms 7296 KB Output isn't correct
24 Incorrect 22 ms 7296 KB Output isn't correct
25 Incorrect 21 ms 7160 KB Output isn't correct
26 Incorrect 23 ms 7040 KB Output isn't correct
27 Incorrect 32 ms 7360 KB Output isn't correct
28 Incorrect 28 ms 7288 KB Output isn't correct
29 Incorrect 37 ms 8568 KB Output isn't correct
30 Incorrect 58 ms 11128 KB Output isn't correct
31 Incorrect 23 ms 7672 KB Output isn't correct
32 Incorrect 24 ms 7416 KB Output isn't correct
33 Incorrect 24 ms 7416 KB Output isn't correct
34 Incorrect 25 ms 7800 KB Output isn't correct
35 Incorrect 25 ms 7416 KB Output isn't correct
36 Incorrect 39 ms 7544 KB Output isn't correct
37 Incorrect 29 ms 7900 KB Output isn't correct
38 Incorrect 29 ms 7800 KB Output isn't correct
39 Incorrect 28 ms 7800 KB Output isn't correct
40 Incorrect 59 ms 9948 KB Output isn't correct
41 Incorrect 81 ms 12668 KB Output isn't correct