# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
58247 | 2018-07-17T08:57:11 Z | evpipis | 007 (CEOI14_007) | C++14 | 1000 ms | 16508 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back typedef long long ll; typedef pair<int, int> ii; const int len = 2e5+5, inf = 1e9; int dis[len], tim[len]; int n, m, s1, s2, t1, t2; queue<int> myq; vector<int> adj[len]; bool check(int x){ for (int i = 1; i <= n; i++) dis[i] = inf; if (0 < tim[s2]+x) dis[s2] = 0, myq.push(s2); while (!myq.empty()){ int u = myq.front(); myq.pop(); for (int j = 0; j < adj[u].size(); j++){ int v = adj[u][j]; if (dis[v] == inf && dis[u]+1 != tim[v]+x) dis[v] = dis[u]+1, myq.push(v); } } //return (dis[t1] == -1 && dis[t2] == -1); //if (dis[t1]+1 < tim[t1]+x || dis[t2]+1 < tim[t2]+x) // return false; //return true; return (tim[t1]+x <= dis[t1] && tim[t2]+x <= dis[t2]); } int bs(){ int l = 0, r = n, ans = -1; while (l <= r){ int mid = (l+r)/2; if (check(mid)) l = mid+1, ans = mid; else r = mid-1; } return ans; } int main(){ scanf("%d %d %d %d %d %d", &n, &m, &s1, &s2, &t1, &t2); for (int i = 0; i < m; i++){ int a, b; scanf("%d %d", &a, &b); adj[a].pb(b); adj[b].pb(a); } for (int i = 1; i <= n; i++) tim[i] = -1; tim[s1] = 0, myq.push(s1); while (!myq.empty()){ int u = myq.front(); myq.pop(); for (int j = 0; j < adj[u].size(); j++){ int v = adj[u][j]; if (tim[v] == -1) tim[v] = tim[u]+1, myq.push(v); } } printf("%d\n", max(bs() - 1, -1)); return 0; } /* 9 10 9 8 1 2 1 2 2 3 3 1 2 4 4 5 5 2 5 7 7 6 7 8 7 9 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 6 ms | 4984 KB | Partially correct |
2 | Partially correct | 8 ms | 5092 KB | Partially correct |
3 | Partially correct | 6 ms | 5168 KB | Partially correct |
4 | Correct | 5 ms | 5168 KB | Output is correct |
5 | Correct | 6 ms | 5204 KB | Output is correct |
6 | Partially correct | 7 ms | 5372 KB | Partially correct |
7 | Partially correct | 5 ms | 5372 KB | Partially correct |
8 | Correct | 7 ms | 5372 KB | Output is correct |
9 | Partially correct | 8 ms | 5372 KB | Partially correct |
10 | Partially correct | 6 ms | 5372 KB | Partially correct |
11 | Partially correct | 6 ms | 5372 KB | Partially correct |
12 | Correct | 7 ms | 5372 KB | Output is correct |
13 | Partially correct | 6 ms | 5372 KB | Partially correct |
14 | Correct | 5 ms | 5372 KB | Output is correct |
15 | Partially correct | 6 ms | 5372 KB | Partially correct |
16 | Correct | 7 ms | 5372 KB | Output is correct |
17 | Correct | 7 ms | 5372 KB | Output is correct |
18 | Correct | 8 ms | 5372 KB | Output is correct |
19 | Partially correct | 8 ms | 5372 KB | Partially correct |
20 | Partially correct | 7 ms | 5372 KB | Partially correct |
21 | Partially correct | 6 ms | 5372 KB | Partially correct |
22 | Partially correct | 8 ms | 5372 KB | Partially correct |
23 | Partially correct | 8 ms | 5372 KB | Partially correct |
24 | Correct | 7 ms | 5372 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 60 ms | 6908 KB | Partially correct |
2 | Correct | 70 ms | 7548 KB | Output is correct |
3 | Partially correct | 59 ms | 7548 KB | Partially correct |
4 | Correct | 103 ms | 7736 KB | Output is correct |
5 | Partially correct | 66 ms | 7736 KB | Partially correct |
6 | Partially correct | 60 ms | 7736 KB | Partially correct |
7 | Partially correct | 69 ms | 7736 KB | Partially correct |
8 | Partially correct | 76 ms | 7736 KB | Partially correct |
9 | Correct | 98 ms | 7736 KB | Output is correct |
10 | Partially correct | 327 ms | 12004 KB | Partially correct |
11 | Correct | 162 ms | 12004 KB | Output is correct |
12 | Partially correct | 319 ms | 12004 KB | Partially correct |
13 | Correct | 273 ms | 12004 KB | Output is correct |
14 | Correct | 134 ms | 12004 KB | Output is correct |
15 | Partially correct | 198 ms | 12004 KB | Partially correct |
16 | Partially correct | 210 ms | 12004 KB | Partially correct |
17 | Partially correct | 189 ms | 12004 KB | Partially correct |
18 | Correct | 300 ms | 12004 KB | Output is correct |
19 | Partially correct | 257 ms | 12004 KB | Partially correct |
20 | Correct | 765 ms | 13620 KB | Output is correct |
21 | Correct | 601 ms | 13620 KB | Output is correct |
22 | Partially correct | 588 ms | 13620 KB | Partially correct |
23 | Partially correct | 735 ms | 13620 KB | Partially correct |
24 | Partially correct | 370 ms | 13620 KB | Partially correct |
25 | Correct | 605 ms | 13620 KB | Output is correct |
26 | Partially correct | 463 ms | 13620 KB | Partially correct |
27 | Partially correct | 631 ms | 13620 KB | Partially correct |
28 | Partially correct | 796 ms | 13620 KB | Partially correct |
29 | Partially correct | 377 ms | 13620 KB | Partially correct |
30 | Correct | 646 ms | 14516 KB | Output is correct |
31 | Correct | 439 ms | 14516 KB | Output is correct |
32 | Partially correct | 492 ms | 14516 KB | Partially correct |
33 | Partially correct | 408 ms | 14516 KB | Partially correct |
34 | Correct | 737 ms | 14516 KB | Output is correct |
35 | Correct | 525 ms | 14516 KB | Output is correct |
36 | Correct | 544 ms | 14516 KB | Output is correct |
37 | Partially correct | 551 ms | 14516 KB | Partially correct |
38 | Partially correct | 688 ms | 14516 KB | Partially correct |
39 | Partially correct | 922 ms | 14516 KB | Partially correct |
40 | Correct | 735 ms | 14516 KB | Output is correct |
41 | Execution timed out | 1069 ms | 16508 KB | Time limit exceeded |