# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
144041 |
2019-08-15T18:57:55 Z |
neki |
007 (CEOI14_007) |
C++14 |
|
323 ms |
23800 KB |
#include <bits/stdc++.h>
#define loop(i, a, b) for(int i=a;i<b;i++)
#define maxn 201000
using namespace std;
typedef long long ll;
vector<int> edges[maxn];
int main(){
int n, m, p0, pdr, s1, s2, a, b;cin >>n>> m>> p0>> pdr>> s1>> s2;
loop(i, 0, m) scanf("%d%d", &a, &b), edges[a].push_back(b), edges[b].push_back(a);
int ddr[maxn], d0[maxn];memset(d0, -1, sizeof(d0));memset(ddr, -1, sizeof(ddr));
d0[p0]=0;ddr[pdr]=0;
queue<int> q;
q.push(p0);
while(q.size()){
int u=q.front(); q.pop();
for(auto&& v:edges[u]) if(d0[v]==-1) q.push(v), d0[v]=d0[u]+1;
}
q.push(pdr);
while(q.size()){
int u=q.front(); q.pop();
for(auto&& v:edges[u]) if(ddr[v]==-1) q.push(v), ddr[v]=ddr[u]+1;
}
if(ddr[s1]<ddr[s2]) cout <<max(ddr[s1]-d0[s1], -1);
else cout <<max(ddr[s2]-d0[s2], -1);
}
Compilation message
007.cpp: In function 'int main()':
007.cpp:11:63: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
loop(i, 0, m) scanf("%d%d", &a, &b), edges[a].push_back(b), edges[b].push_back(a);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
2 |
Correct |
7 ms |
6648 KB |
Output is correct |
3 |
Correct |
8 ms |
6648 KB |
Output is correct |
4 |
Incorrect |
7 ms |
6648 KB |
Output isn't correct |
5 |
Incorrect |
7 ms |
6648 KB |
Output isn't correct |
6 |
Correct |
7 ms |
6648 KB |
Output is correct |
7 |
Correct |
7 ms |
6648 KB |
Output is correct |
8 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
9 |
Correct |
7 ms |
6648 KB |
Output is correct |
10 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
11 |
Correct |
8 ms |
6648 KB |
Output is correct |
12 |
Incorrect |
9 ms |
6648 KB |
Output isn't correct |
13 |
Correct |
9 ms |
6648 KB |
Output is correct |
14 |
Incorrect |
7 ms |
6648 KB |
Output isn't correct |
15 |
Correct |
7 ms |
6648 KB |
Output is correct |
16 |
Incorrect |
8 ms |
6620 KB |
Output isn't correct |
17 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
18 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
19 |
Correct |
8 ms |
6648 KB |
Output is correct |
20 |
Correct |
8 ms |
6648 KB |
Output is correct |
21 |
Correct |
8 ms |
6648 KB |
Output is correct |
22 |
Correct |
8 ms |
6652 KB |
Output is correct |
23 |
Correct |
8 ms |
6620 KB |
Output is correct |
24 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
8440 KB |
Output is correct |
2 |
Incorrect |
40 ms |
9104 KB |
Output isn't correct |
3 |
Correct |
33 ms |
8436 KB |
Output is correct |
4 |
Incorrect |
43 ms |
9212 KB |
Output isn't correct |
5 |
Correct |
31 ms |
8284 KB |
Output is correct |
6 |
Correct |
32 ms |
8696 KB |
Output is correct |
7 |
Correct |
34 ms |
8696 KB |
Output is correct |
8 |
Correct |
36 ms |
8696 KB |
Output is correct |
9 |
Incorrect |
52 ms |
9592 KB |
Output isn't correct |
10 |
Correct |
194 ms |
18044 KB |
Output is correct |
11 |
Incorrect |
67 ms |
10468 KB |
Output isn't correct |
12 |
Correct |
82 ms |
11640 KB |
Output is correct |
13 |
Incorrect |
69 ms |
10924 KB |
Output isn't correct |
14 |
Correct |
62 ms |
10104 KB |
Output is correct |
15 |
Correct |
87 ms |
11640 KB |
Output is correct |
16 |
Correct |
94 ms |
12012 KB |
Output is correct |
17 |
Correct |
112 ms |
11344 KB |
Output is correct |
18 |
Incorrect |
77 ms |
11256 KB |
Output isn't correct |
19 |
Correct |
128 ms |
13692 KB |
Output is correct |
20 |
Incorrect |
219 ms |
19448 KB |
Output isn't correct |
21 |
Incorrect |
111 ms |
13560 KB |
Output isn't correct |
22 |
Correct |
105 ms |
12764 KB |
Output is correct |
23 |
Correct |
113 ms |
13560 KB |
Output is correct |
24 |
Correct |
113 ms |
13460 KB |
Output is correct |
25 |
Incorrect |
103 ms |
13048 KB |
Output isn't correct |
26 |
Correct |
102 ms |
12792 KB |
Output is correct |
27 |
Correct |
116 ms |
13564 KB |
Output is correct |
28 |
Correct |
138 ms |
13560 KB |
Output is correct |
29 |
Correct |
155 ms |
15740 KB |
Output is correct |
30 |
Incorrect |
234 ms |
20344 KB |
Output isn't correct |
31 |
Incorrect |
141 ms |
14772 KB |
Output isn't correct |
32 |
Correct |
129 ms |
13560 KB |
Output is correct |
33 |
Correct |
119 ms |
13816 KB |
Output is correct |
34 |
Incorrect |
135 ms |
14276 KB |
Output isn't correct |
35 |
Incorrect |
169 ms |
13832 KB |
Output isn't correct |
36 |
Incorrect |
171 ms |
14172 KB |
Output isn't correct |
37 |
Correct |
147 ms |
15188 KB |
Output is correct |
38 |
Correct |
145 ms |
14968 KB |
Output is correct |
39 |
Correct |
166 ms |
14964 KB |
Output is correct |
40 |
Incorrect |
253 ms |
18788 KB |
Output isn't correct |
41 |
Correct |
323 ms |
23800 KB |
Output is correct |