# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
426012 | 2021-06-13T12:58:42 Z | duality | From Hacks to Snitches (BOI21_watchmen) | C++11 | 6000 ms | 117196 KB |
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef long long int LLI; typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pii> vpii; vi adjList[250000]; pair<int,pii> p[250000]; vi dist[250000]; priority_queue<pii> H; set<int> seen[250000]; int main() { int i,j; int N,M,K; int u,v,l; scanf("%d %d",&N,&M); for (i = 0; i < M; i++) { scanf("%d %d",&u,&v); u--,v--; adjList[u].pb(v); adjList[v].pb(u); } scanf("%d",&K); for (i = 0; i < K; i++) { scanf("%d",&l); for (j = 0; j < l; j++) scanf("%d",&v),p[v-1] = mp(l,mp(j,i)); } for (i = 0; i < N; i++) { if (p[i].first == 0) p[i].first = 1; dist[i].resize(p[i].first); fill(dist[i].begin(),dist[i].end(),-1); } dist[0][0] = 0,H.push(mp(0,0)); while (!H.empty()) { int u = H.top().second; int d = -H.top().first; H.pop(); if (d > dist[u][d % p[u].first]) continue; else if (u == N-1) { printf("%d\n",d); return 0; } for (i = 0; i < adjList[u].size(); i++) { int v = adjList[u][i],t = d; for (j = 0; j < p[v].first; j++) { int bad = 0; if (p[v].first != 1) { if (((d+1) % p[v].first) == p[v].second.first) bad = 1; if (((d % p[v].first) == p[v].second.first) && (p[u].second.second == p[v].second.second) \ && (p[u].second.first == ((p[v].second.first+1) % p[v].first))) bad = 1; } if (!bad) { if ((dist[v][(d+1) % p[v].first] == -1) || (d+1 < dist[v][(d+1) % p[v].first])) { dist[v][(d+1) % p[v].first] = d+1; H.push(mp(-(d+1),v)); } } d++; if ((p[u].first != 1) && ((d % p[u].first) == p[u].second.first)) break; } d = t; } } printf("impossible\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 24900 KB | Output is correct |
2 | Correct | 203 ms | 31272 KB | Output is correct |
3 | Correct | 200 ms | 31864 KB | Output is correct |
4 | Correct | 2183 ms | 32124 KB | Output is correct |
5 | Correct | 22 ms | 23884 KB | Output is correct |
6 | Correct | 192 ms | 31932 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 24884 KB | Output is correct |
2 | Correct | 177 ms | 31364 KB | Output is correct |
3 | Correct | 193 ms | 31940 KB | Output is correct |
4 | Correct | 2254 ms | 32196 KB | Output is correct |
5 | Correct | 25 ms | 23884 KB | Output is correct |
6 | Correct | 135 ms | 31900 KB | Output is correct |
7 | Correct | 163 ms | 31684 KB | Output is correct |
8 | Correct | 152 ms | 31684 KB | Output is correct |
9 | Correct | 112 ms | 31652 KB | Output is correct |
10 | Correct | 431 ms | 31980 KB | Output is correct |
11 | Correct | 138 ms | 31812 KB | Output is correct |
12 | Correct | 145 ms | 31720 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 24884 KB | Output is correct |
2 | Correct | 177 ms | 31364 KB | Output is correct |
3 | Correct | 193 ms | 31940 KB | Output is correct |
4 | Correct | 2254 ms | 32196 KB | Output is correct |
5 | Correct | 25 ms | 23884 KB | Output is correct |
6 | Correct | 135 ms | 31900 KB | Output is correct |
7 | Correct | 163 ms | 31684 KB | Output is correct |
8 | Correct | 152 ms | 31684 KB | Output is correct |
9 | Correct | 112 ms | 31652 KB | Output is correct |
10 | Correct | 431 ms | 31980 KB | Output is correct |
11 | Correct | 138 ms | 31812 KB | Output is correct |
12 | Correct | 145 ms | 31720 KB | Output is correct |
13 | Correct | 35 ms | 25456 KB | Output is correct |
14 | Correct | 143 ms | 32440 KB | Output is correct |
15 | Correct | 146 ms | 31876 KB | Output is correct |
16 | Correct | 2189 ms | 32196 KB | Output is correct |
17 | Correct | 24 ms | 23884 KB | Output is correct |
18 | Correct | 129 ms | 31832 KB | Output is correct |
19 | Correct | 171 ms | 31816 KB | Output is correct |
20 | Correct | 155 ms | 31684 KB | Output is correct |
21 | Correct | 174 ms | 31664 KB | Output is correct |
22 | Correct | 393 ms | 32024 KB | Output is correct |
23 | Correct | 169 ms | 31812 KB | Output is correct |
24 | Correct | 155 ms | 31768 KB | Output is correct |
25 | Correct | 2941 ms | 113360 KB | Output is correct |
26 | Correct | 3025 ms | 117196 KB | Output is correct |
27 | Correct | 3128 ms | 113208 KB | Output is correct |
28 | Correct | 1900 ms | 117056 KB | Output is correct |
29 | Execution timed out | 6088 ms | 109564 KB | Time limit exceeded |
30 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 24884 KB | Output is correct |
2 | Correct | 177 ms | 31364 KB | Output is correct |
3 | Correct | 193 ms | 31940 KB | Output is correct |
4 | Correct | 2254 ms | 32196 KB | Output is correct |
5 | Correct | 25 ms | 23884 KB | Output is correct |
6 | Correct | 135 ms | 31900 KB | Output is correct |
7 | Correct | 163 ms | 31684 KB | Output is correct |
8 | Correct | 152 ms | 31684 KB | Output is correct |
9 | Correct | 112 ms | 31652 KB | Output is correct |
10 | Correct | 431 ms | 31980 KB | Output is correct |
11 | Correct | 138 ms | 31812 KB | Output is correct |
12 | Correct | 145 ms | 31720 KB | Output is correct |
13 | Correct | 35 ms | 25456 KB | Output is correct |
14 | Correct | 143 ms | 32440 KB | Output is correct |
15 | Correct | 146 ms | 31876 KB | Output is correct |
16 | Correct | 2189 ms | 32196 KB | Output is correct |
17 | Correct | 24 ms | 23884 KB | Output is correct |
18 | Correct | 129 ms | 31832 KB | Output is correct |
19 | Correct | 171 ms | 31816 KB | Output is correct |
20 | Correct | 155 ms | 31684 KB | Output is correct |
21 | Correct | 174 ms | 31664 KB | Output is correct |
22 | Correct | 393 ms | 32024 KB | Output is correct |
23 | Correct | 169 ms | 31812 KB | Output is correct |
24 | Correct | 155 ms | 31768 KB | Output is correct |
25 | Correct | 2941 ms | 113360 KB | Output is correct |
26 | Correct | 3025 ms | 117196 KB | Output is correct |
27 | Correct | 3128 ms | 113208 KB | Output is correct |
28 | Correct | 1900 ms | 117056 KB | Output is correct |
29 | Execution timed out | 6088 ms | 109564 KB | Time limit exceeded |
30 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 24900 KB | Output is correct |
2 | Correct | 203 ms | 31272 KB | Output is correct |
3 | Correct | 200 ms | 31864 KB | Output is correct |
4 | Correct | 2183 ms | 32124 KB | Output is correct |
5 | Correct | 22 ms | 23884 KB | Output is correct |
6 | Correct | 192 ms | 31932 KB | Output is correct |
7 | Correct | 33 ms | 24884 KB | Output is correct |
8 | Correct | 177 ms | 31364 KB | Output is correct |
9 | Correct | 193 ms | 31940 KB | Output is correct |
10 | Correct | 2254 ms | 32196 KB | Output is correct |
11 | Correct | 25 ms | 23884 KB | Output is correct |
12 | Correct | 135 ms | 31900 KB | Output is correct |
13 | Correct | 163 ms | 31684 KB | Output is correct |
14 | Correct | 152 ms | 31684 KB | Output is correct |
15 | Correct | 112 ms | 31652 KB | Output is correct |
16 | Correct | 431 ms | 31980 KB | Output is correct |
17 | Correct | 138 ms | 31812 KB | Output is correct |
18 | Correct | 145 ms | 31720 KB | Output is correct |
19 | Correct | 17 ms | 23756 KB | Output is correct |
20 | Correct | 16 ms | 23696 KB | Output is correct |
21 | Correct | 16 ms | 23744 KB | Output is correct |
22 | Correct | 33 ms | 25528 KB | Output is correct |
23 | Correct | 183 ms | 32516 KB | Output is correct |
24 | Correct | 190 ms | 31844 KB | Output is correct |
25 | Correct | 2180 ms | 32124 KB | Output is correct |
26 | Correct | 25 ms | 23884 KB | Output is correct |
27 | Correct | 179 ms | 31852 KB | Output is correct |
28 | Correct | 150 ms | 31664 KB | Output is correct |
29 | Correct | 170 ms | 31684 KB | Output is correct |
30 | Correct | 98 ms | 31680 KB | Output is correct |
31 | Correct | 426 ms | 31880 KB | Output is correct |
32 | Correct | 153 ms | 31816 KB | Output is correct |
33 | Correct | 111 ms | 31820 KB | Output is correct |
34 | Correct | 3383 ms | 113504 KB | Output is correct |
35 | Correct | 3056 ms | 109784 KB | Output is correct |
36 | Correct | 3344 ms | 109724 KB | Output is correct |
37 | Incorrect | 3091 ms | 115492 KB | Output isn't correct |
38 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 24900 KB | Output is correct |
2 | Correct | 203 ms | 31272 KB | Output is correct |
3 | Correct | 200 ms | 31864 KB | Output is correct |
4 | Correct | 2183 ms | 32124 KB | Output is correct |
5 | Correct | 22 ms | 23884 KB | Output is correct |
6 | Correct | 192 ms | 31932 KB | Output is correct |
7 | Correct | 33 ms | 24884 KB | Output is correct |
8 | Correct | 177 ms | 31364 KB | Output is correct |
9 | Correct | 193 ms | 31940 KB | Output is correct |
10 | Correct | 2254 ms | 32196 KB | Output is correct |
11 | Correct | 25 ms | 23884 KB | Output is correct |
12 | Correct | 135 ms | 31900 KB | Output is correct |
13 | Correct | 163 ms | 31684 KB | Output is correct |
14 | Correct | 152 ms | 31684 KB | Output is correct |
15 | Correct | 112 ms | 31652 KB | Output is correct |
16 | Correct | 431 ms | 31980 KB | Output is correct |
17 | Correct | 138 ms | 31812 KB | Output is correct |
18 | Correct | 145 ms | 31720 KB | Output is correct |
19 | Correct | 35 ms | 25456 KB | Output is correct |
20 | Correct | 143 ms | 32440 KB | Output is correct |
21 | Correct | 146 ms | 31876 KB | Output is correct |
22 | Correct | 2189 ms | 32196 KB | Output is correct |
23 | Correct | 24 ms | 23884 KB | Output is correct |
24 | Correct | 129 ms | 31832 KB | Output is correct |
25 | Correct | 171 ms | 31816 KB | Output is correct |
26 | Correct | 155 ms | 31684 KB | Output is correct |
27 | Correct | 174 ms | 31664 KB | Output is correct |
28 | Correct | 393 ms | 32024 KB | Output is correct |
29 | Correct | 169 ms | 31812 KB | Output is correct |
30 | Correct | 155 ms | 31768 KB | Output is correct |
31 | Correct | 2941 ms | 113360 KB | Output is correct |
32 | Correct | 3025 ms | 117196 KB | Output is correct |
33 | Correct | 3128 ms | 113208 KB | Output is correct |
34 | Correct | 1900 ms | 117056 KB | Output is correct |
35 | Execution timed out | 6088 ms | 109564 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 24900 KB | Output is correct |
2 | Correct | 203 ms | 31272 KB | Output is correct |
3 | Correct | 200 ms | 31864 KB | Output is correct |
4 | Correct | 2183 ms | 32124 KB | Output is correct |
5 | Correct | 22 ms | 23884 KB | Output is correct |
6 | Correct | 192 ms | 31932 KB | Output is correct |
7 | Correct | 33 ms | 24884 KB | Output is correct |
8 | Correct | 177 ms | 31364 KB | Output is correct |
9 | Correct | 193 ms | 31940 KB | Output is correct |
10 | Correct | 2254 ms | 32196 KB | Output is correct |
11 | Correct | 25 ms | 23884 KB | Output is correct |
12 | Correct | 135 ms | 31900 KB | Output is correct |
13 | Correct | 163 ms | 31684 KB | Output is correct |
14 | Correct | 152 ms | 31684 KB | Output is correct |
15 | Correct | 112 ms | 31652 KB | Output is correct |
16 | Correct | 431 ms | 31980 KB | Output is correct |
17 | Correct | 138 ms | 31812 KB | Output is correct |
18 | Correct | 145 ms | 31720 KB | Output is correct |
19 | Correct | 35 ms | 25456 KB | Output is correct |
20 | Correct | 143 ms | 32440 KB | Output is correct |
21 | Correct | 146 ms | 31876 KB | Output is correct |
22 | Correct | 2189 ms | 32196 KB | Output is correct |
23 | Correct | 24 ms | 23884 KB | Output is correct |
24 | Correct | 129 ms | 31832 KB | Output is correct |
25 | Correct | 171 ms | 31816 KB | Output is correct |
26 | Correct | 155 ms | 31684 KB | Output is correct |
27 | Correct | 174 ms | 31664 KB | Output is correct |
28 | Correct | 393 ms | 32024 KB | Output is correct |
29 | Correct | 169 ms | 31812 KB | Output is correct |
30 | Correct | 155 ms | 31768 KB | Output is correct |
31 | Correct | 2941 ms | 113360 KB | Output is correct |
32 | Correct | 3025 ms | 117196 KB | Output is correct |
33 | Correct | 3128 ms | 113208 KB | Output is correct |
34 | Correct | 1900 ms | 117056 KB | Output is correct |
35 | Execution timed out | 6088 ms | 109564 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |