답안 #43398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43398 2018-03-15T19:59:24 Z XmtosX 007 (CEOI14_007) C++14
0 / 100
565 ms 104324 KB
#include <bits/stdc++.h>
using namespace std;
int n,m,st1,st2,a,b;
vector <int> v[300005];
int bs (int x,int y)
{
    queue<int> q;
    int lvl[300005]={0};
    lvl[x]=1;
    q.push(x);
    while (!q.empty())
    {
        int node=q.front();
        q.pop();
        if (node==y)
            return lvl[y];
        for (int i=0;i<v[node].size();i++)
        {
            if (!lvl[v[node][i]])
            {
                lvl[v[node][i]]=lvl[node]+1;
                q.push(v[node][i]);
            }
        }
    }
}
int main()
{
    cin >>n>>m>>st1>>st2>>a>>b;
    for (int i=0;i<m;i++)
    {
        int x,y;
        cin >>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int ans1= (bs(st2,a));
    int ans2=(bs(st2,b));
    int x;
    if (ans2==ans1)
        x=max(bs(st1,a),bs(st1,b));
    else if (ans1<ans2)
        x=bs(st1,a);
    else
        x=bs(st1,b);
    ans1=min(ans1,ans2);
    if (x>ans1)
        cout <<-1;
    else
        cout<<ans1-x;
    return 0;
}

Compilation message

007.cpp: In function 'int bs(int, int)':
007.cpp:17:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i=0;i<v[node].size();i++)
                       ^
007.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8568 KB Output is correct
2 Correct 8 ms 8568 KB Output is correct
3 Correct 8 ms 8656 KB Output is correct
4 Incorrect 8 ms 8692 KB Output isn't correct
5 Incorrect 8 ms 8716 KB Output isn't correct
6 Correct 8 ms 8720 KB Output is correct
7 Correct 9 ms 8812 KB Output is correct
8 Incorrect 8 ms 8820 KB Output isn't correct
9 Correct 8 ms 8840 KB Output is correct
10 Correct 8 ms 8840 KB Output is correct
11 Correct 8 ms 8848 KB Output is correct
12 Incorrect 8 ms 8852 KB Output isn't correct
13 Correct 11 ms 8856 KB Output is correct
14 Incorrect 8 ms 8948 KB Output isn't correct
15 Correct 8 ms 8972 KB Output is correct
16 Incorrect 8 ms 8976 KB Output isn't correct
17 Incorrect 8 ms 9000 KB Output isn't correct
18 Incorrect 8 ms 9024 KB Output isn't correct
19 Correct 9 ms 9044 KB Output is correct
20 Correct 8 ms 9056 KB Output is correct
21 Correct 8 ms 9064 KB Output is correct
22 Correct 8 ms 9072 KB Output is correct
23 Correct 8 ms 9080 KB Output is correct
24 Incorrect 9 ms 9088 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 10764 KB Output is correct
2 Incorrect 71 ms 12012 KB Output isn't correct
3 Correct 66 ms 12048 KB Output is correct
4 Incorrect 68 ms 13336 KB Output isn't correct
5 Correct 49 ms 13336 KB Output is correct
6 Correct 50 ms 13888 KB Output is correct
7 Correct 61 ms 14572 KB Output is correct
8 Correct 62 ms 15080 KB Output is correct
9 Incorrect 91 ms 16540 KB Output isn't correct
10 Correct 383 ms 25952 KB Output is correct
11 Incorrect 109 ms 25952 KB Output isn't correct
12 Correct 143 ms 25952 KB Output is correct
13 Incorrect 113 ms 26616 KB Output isn't correct
14 Correct 94 ms 27008 KB Output is correct
15 Correct 136 ms 29480 KB Output is correct
16 Correct 140 ms 31264 KB Output is correct
17 Correct 120 ms 32016 KB Output is correct
18 Incorrect 115 ms 33420 KB Output isn't correct
19 Correct 232 ms 37044 KB Output is correct
20 Incorrect 454 ms 45360 KB Output isn't correct
21 Incorrect 190 ms 45360 KB Output isn't correct
22 Correct 169 ms 46236 KB Output is correct
23 Correct 180 ms 48624 KB Output is correct
24 Correct 183 ms 50512 KB Output is correct
25 Incorrect 176 ms 52164 KB Output isn't correct
26 Correct 155 ms 53648 KB Output is correct
27 Correct 188 ms 56300 KB Output is correct
28 Correct 177 ms 58244 KB Output is correct
29 Correct 291 ms 62444 KB Output is correct
30 Incorrect 449 ms 70272 KB Output isn't correct
31 Incorrect 219 ms 70612 KB Output isn't correct
32 Correct 217 ms 71692 KB Output is correct
33 Correct 190 ms 73972 KB Output is correct
34 Incorrect 241 ms 76372 KB Output isn't correct
35 Incorrect 184 ms 78264 KB Output isn't correct
36 Incorrect 187 ms 80528 KB Output isn't correct
37 Correct 224 ms 83724 KB Output is correct
38 Correct 216 ms 86044 KB Output is correct
39 Correct 249 ms 88688 KB Output is correct
40 Incorrect 373 ms 94688 KB Output isn't correct
41 Correct 565 ms 104324 KB Output is correct