답안 #43407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43407 2018-03-15T20:35:23 Z XmtosX 007 (CEOI14_007) C++14
0 / 100
586 ms 19052 KB
#include <bits/stdc++.h>
using namespace std;
int n,m,st1,st2,a,b;
vector <int> v[300005];
int lvl[300005][2];
void bs (int x,int y)
{
    queue<int> q;
    lvl[x][y]=1;
    q.push(x);
    while (!q.empty())
    {
        int node=q.front();
        q.pop();
        for (int i=0;i<v[node].size();i++)
        {
            if (!lvl[v[node][i]][y])
            {
                lvl[v[node][i]][y]=lvl[node][y]+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);
    }
    bs(st1,1);
    bs(st2,0);
    vector <int> v1;
    for (int i=0;i<v[a].size();i++)
    {
        if (v[a][i]!=b&&lvl[v[a][i]][0]<lvl[a][0])
            v1.push_back(v[a][i]);
    }
    for (int i=0;i<v[b].size();i++)
    {
        if (v[b][i]!=a&&lvl[v[b][i]][0]<lvl[b][0])
            v1.push_back(v[b][i]);
    }
    int ans=-1;
    for (int i=0;i<v1.size();i++)
    {
        ans=max(ans,lvl[v1[i]][0]-lvl[v1[i]][1]+1);
    }
    lvl[a][1]++;
    lvl[b][1]++;
    ans=max(ans,lvl[a][0]-lvl[a][1]);
    ans=max(ans,lvl[b][0]-lvl[b][1]);
    cout <<ans;
    return 0;
}

Compilation message

007.cpp: In function 'void bs(int, int)':
007.cpp:15:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i=0;i<v[node].size();i++)
                       ^
007.cpp: In function 'int main()':
007.cpp:38:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v[a].size();i++)
                   ^
007.cpp:43:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v[b].size();i++)
                   ^
007.cpp:49:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v1.size();i++)
                   ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 7288 KB Output isn't correct
2 Partially correct 7 ms 7344 KB Partially correct
3 Partially correct 6 ms 7464 KB Partially correct
4 Incorrect 9 ms 7536 KB Output isn't correct
5 Correct 7 ms 7572 KB Output is correct
6 Incorrect 7 ms 7644 KB Output isn't correct
7 Correct 8 ms 7660 KB Output is correct
8 Correct 8 ms 7660 KB Output is correct
9 Correct 9 ms 7660 KB Output is correct
10 Correct 7 ms 7660 KB Output is correct
11 Incorrect 7 ms 7660 KB Output isn't correct
12 Incorrect 7 ms 7664 KB Output isn't correct
13 Correct 9 ms 7664 KB Output is correct
14 Incorrect 7 ms 7664 KB Output isn't correct
15 Incorrect 9 ms 7664 KB Output isn't correct
16 Correct 9 ms 7664 KB Output is correct
17 Incorrect 8 ms 7664 KB Output isn't correct
18 Correct 10 ms 7752 KB Output is correct
19 Partially correct 10 ms 7760 KB Partially correct
20 Correct 7 ms 7760 KB Output is correct
21 Incorrect 7 ms 7760 KB Output isn't correct
22 Incorrect 7 ms 7760 KB Output isn't correct
23 Incorrect 8 ms 7760 KB Output isn't correct
24 Correct 8 ms 7760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 9144 KB Output is correct
2 Incorrect 61 ms 9964 KB Output isn't correct
3 Correct 57 ms 9964 KB Output is correct
4 Incorrect 82 ms 10092 KB Output isn't correct
5 Incorrect 47 ms 10092 KB Output isn't correct
6 Incorrect 48 ms 10092 KB Output isn't correct
7 Incorrect 56 ms 10092 KB Output isn't correct
8 Incorrect 53 ms 10092 KB Output isn't correct
9 Correct 85 ms 10092 KB Output is correct
10 Partially correct 369 ms 14444 KB Partially correct
11 Incorrect 98 ms 14444 KB Output isn't correct
12 Correct 144 ms 14444 KB Output is correct
13 Correct 117 ms 14444 KB Output is correct
14 Correct 87 ms 14444 KB Output is correct
15 Correct 127 ms 14444 KB Output is correct
16 Incorrect 143 ms 14444 KB Output isn't correct
17 Incorrect 123 ms 14444 KB Output isn't correct
18 Incorrect 133 ms 14444 KB Output isn't correct
19 Partially correct 217 ms 14444 KB Partially correct
20 Correct 435 ms 15852 KB Output is correct
21 Incorrect 181 ms 15852 KB Output isn't correct
22 Correct 158 ms 15852 KB Output is correct
23 Correct 196 ms 15852 KB Output is correct
24 Correct 178 ms 15852 KB Output is correct
25 Incorrect 164 ms 15852 KB Output isn't correct
26 Correct 163 ms 15852 KB Output is correct
27 Incorrect 190 ms 15852 KB Output isn't correct
28 Incorrect 200 ms 15852 KB Output isn't correct
29 Partially correct 272 ms 15852 KB Partially correct
30 Correct 499 ms 16800 KB Output is correct
31 Incorrect 207 ms 16800 KB Output isn't correct
32 Correct 183 ms 16800 KB Output is correct
33 Correct 194 ms 16800 KB Output is correct
34 Incorrect 242 ms 16800 KB Output isn't correct
35 Correct 188 ms 16800 KB Output is correct
36 Correct 203 ms 16800 KB Output is correct
37 Incorrect 237 ms 16800 KB Output isn't correct
38 Incorrect 252 ms 16800 KB Output isn't correct
39 Incorrect 250 ms 16800 KB Output isn't correct
40 Correct 391 ms 16800 KB Output is correct
41 Partially correct 586 ms 19052 KB Partially correct