# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101413 | 2019-03-19T01:16:38 Z | jamielim | 007 (CEOI14_007) | C++14 | 440 ms | 15728 KB |
#include <bits/stdc++.h> using namespace std; int main(){ int n,m; scanf("%d%d",&n,&m); int s,d,a,b; scanf("%d%d%d%d",&s,&d,&a,&b); s--; d--; a--; b--; vector<int> adj[n]; int u,v; for(int i=0;i<m;i++){ scanf("%d%d",&u,&v); u--; v--; adj[u].push_back(v); adj[v].push_back(u); } int dist[2][n]; for(int i=0;i<n;i++)dist[0][i]=dist[1][i]=1000000010; priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq; pq.push(make_pair(0,a)); dist[0][a]=0; while(!pq.empty()){ pair<int,int> cur=pq.top();pq.pop(); for(int i=0;i<(int)adj[cur.second].size();i++){ if(dist[0][adj[cur.second][i]]>dist[0][cur.second]+1){ dist[0][adj[cur.second][i]]=dist[0][cur.second]+1; pq.push(make_pair(dist[0][adj[cur.second][i]],adj[cur.second][i])); } } } pq.push(make_pair(0,b)); dist[1][b]=0; while(!pq.empty()){ pair<int,int> cur=pq.top();pq.pop(); for(int i=0;i<(int)adj[cur.second].size();i++){ if(dist[1][adj[cur.second][i]]>dist[1][cur.second]+1){ dist[1][adj[cur.second][i]]=dist[1][cur.second]+1; pq.push(make_pair(dist[1][adj[cur.second][i]],adj[cur.second][i])); } } } printf("%d",max(-1,min(dist[0][d]-dist[0][s],dist[1][d]-dist[1][s]))); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Incorrect | 3 ms | 384 KB | Output isn't correct |
5 | Incorrect | 2 ms | 256 KB | Output isn't correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 252 KB | Output is correct |
8 | Incorrect | 2 ms | 256 KB | Output isn't correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 3 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Incorrect | 3 ms | 384 KB | Output isn't correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Incorrect | 3 ms | 256 KB | Output isn't correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Incorrect | 3 ms | 384 KB | Output isn't correct |
17 | Incorrect | 3 ms | 384 KB | Output isn't correct |
18 | Incorrect | 2 ms | 384 KB | Output isn't correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Incorrect | 4 ms | 384 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 3064 KB | Output is correct |
2 | Incorrect | 69 ms | 3960 KB | Output isn't correct |
3 | Correct | 60 ms | 3064 KB | Output is correct |
4 | Incorrect | 63 ms | 4088 KB | Output isn't correct |
5 | Correct | 50 ms | 2816 KB | Output is correct |
6 | Correct | 37 ms | 3064 KB | Output is correct |
7 | Correct | 54 ms | 3528 KB | Output is correct |
8 | Correct | 83 ms | 3576 KB | Output is correct |
9 | Incorrect | 94 ms | 3960 KB | Output isn't correct |
10 | Correct | 253 ms | 8540 KB | Output is correct |
11 | Incorrect | 113 ms | 6008 KB | Output isn't correct |
12 | Correct | 182 ms | 7536 KB | Output is correct |
13 | Incorrect | 158 ms | 6436 KB | Output isn't correct |
14 | Correct | 118 ms | 5488 KB | Output is correct |
15 | Correct | 140 ms | 7544 KB | Output is correct |
16 | Correct | 177 ms | 7996 KB | Output is correct |
17 | Correct | 146 ms | 7224 KB | Output is correct |
18 | Incorrect | 169 ms | 7224 KB | Output isn't correct |
19 | Correct | 197 ms | 8336 KB | Output is correct |
20 | Incorrect | 333 ms | 11256 KB | Output isn't correct |
21 | Incorrect | 188 ms | 10612 KB | Output isn't correct |
22 | Correct | 218 ms | 8952 KB | Output is correct |
23 | Correct | 194 ms | 10232 KB | Output is correct |
24 | Correct | 194 ms | 10180 KB | Output is correct |
25 | Incorrect | 212 ms | 9664 KB | Output isn't correct |
26 | Correct | 163 ms | 9080 KB | Output is correct |
27 | Correct | 221 ms | 10500 KB | Output is correct |
28 | Correct | 212 ms | 10488 KB | Output is correct |
29 | Correct | 213 ms | 10532 KB | Output is correct |
30 | Incorrect | 352 ms | 12280 KB | Output isn't correct |
31 | Incorrect | 194 ms | 11840 KB | Output isn't correct |
32 | Correct | 265 ms | 10232 KB | Output is correct |
33 | Correct | 229 ms | 10616 KB | Output is correct |
34 | Incorrect | 282 ms | 11224 KB | Output isn't correct |
35 | Incorrect | 218 ms | 10716 KB | Output isn't correct |
36 | Incorrect | 226 ms | 11132 KB | Output isn't correct |
37 | Correct | 306 ms | 12444 KB | Output is correct |
38 | Correct | 309 ms | 12152 KB | Output is correct |
39 | Correct | 305 ms | 12280 KB | Output is correct |
40 | Incorrect | 331 ms | 13636 KB | Output isn't correct |
41 | Correct | 440 ms | 15728 KB | Output is correct |