# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131952 | 2019-07-18T05:55:16 Z | 임유진(#3191) | Wild Boar (JOI18_wild_boar) | C++14 | 14531 ms | 1528 KB |
#include <bits/stdc++.h> using namespace std; #define MAXN 505 #define MAXL 100005 #define fi first #define se second typedef long long lint; typedef pair<lint, int> pli; const lint LINF = 1ll << 60; int A[MAXN], B[MAXN], C[MAXN], X[MAXL]; vector<int> ed[2 * MAXN]; vector<lint> dp; vector<int> in[MAXN], out[MAXN]; int main() { int N, M, T, L; int P, Q; scanf("%d%d%d%d", &N, &M, &T, &L); for(int i = 0; i < M; i++) scanf("%d%d%d", A + i, B + i, C + i); for(int i = 0; i < L; i++) scanf("%d", X + i); scanf("%d%d", &P, &Q); X[P - 1] = Q; for(int i = 1; i <= N; i++) { for(int j = 0; j < M; j++) { if(A[j] == i) { out[i].push_back(j); in[i].push_back(j + M); } else if(B[j] == i) { in[i].push_back(j); out[i].push_back(j + M); } } for(auto a : in[i]) for(auto b : out[i]) if(a % M != b % M) ed[a].push_back(b); } dp.resize(2 * M, 0ll); for(auto a : out[X[0]]) dp[a] = C[a % M]; for(int i = 0; i < L - 1; i++) { priority_queue<pli, vector<pli>, greater<pli> > pq; vector<lint> v(2 * M, LINF); for(auto a : out[X[i]]) { v[a] = dp[a]; pq.push(make_pair(dp[a], a)); } swap(dp, v); while(!pq.empty()) { pli t = pq.top(); pq.pop(); if(dp[t.se] != t.fi) continue; for(auto a : ed[t.se]) if(t.fi + C[a % M] < dp[a]) { dp[a] = t.fi + C[a % M]; pq.push(make_pair(dp[a], a)); } } } lint ans = LINF; for(auto a : in[X[L - 1]]) ans = min(ans, dp[a]); printf("%lld", ans == LINF ? -1 : ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 380 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 380 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 3 ms | 376 KB | Output is correct |
27 | Correct | 53 ms | 892 KB | Output is correct |
28 | Correct | 54 ms | 1016 KB | Output is correct |
29 | Correct | 8924 ms | 1152 KB | Output is correct |
30 | Correct | 10514 ms | 1088 KB | Output is correct |
31 | Correct | 14531 ms | 1140 KB | Output is correct |
32 | Correct | 14374 ms | 1140 KB | Output is correct |
33 | Correct | 8109 ms | 1188 KB | Output is correct |
34 | Correct | 8148 ms | 1188 KB | Output is correct |
35 | Correct | 12626 ms | 1016 KB | Output is correct |
36 | Correct | 11374 ms | 1096 KB | Output is correct |
37 | Correct | 8127 ms | 1200 KB | Output is correct |
38 | Correct | 7711 ms | 1196 KB | Output is correct |
39 | Correct | 8687 ms | 1144 KB | Output is correct |
40 | Correct | 7550 ms | 1200 KB | Output is correct |
41 | Correct | 7466 ms | 1144 KB | Output is correct |
42 | Correct | 6912 ms | 1108 KB | Output is correct |
43 | Correct | 6299 ms | 1244 KB | Output is correct |
44 | Correct | 6318 ms | 1204 KB | Output is correct |
45 | Correct | 2335 ms | 1224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 380 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 3 ms | 376 KB | Output is correct |
27 | Correct | 53 ms | 892 KB | Output is correct |
28 | Correct | 54 ms | 1016 KB | Output is correct |
29 | Correct | 8924 ms | 1152 KB | Output is correct |
30 | Correct | 10514 ms | 1088 KB | Output is correct |
31 | Correct | 14531 ms | 1140 KB | Output is correct |
32 | Correct | 14374 ms | 1140 KB | Output is correct |
33 | Correct | 8109 ms | 1188 KB | Output is correct |
34 | Correct | 8148 ms | 1188 KB | Output is correct |
35 | Correct | 12626 ms | 1016 KB | Output is correct |
36 | Correct | 11374 ms | 1096 KB | Output is correct |
37 | Correct | 8127 ms | 1200 KB | Output is correct |
38 | Correct | 7711 ms | 1196 KB | Output is correct |
39 | Correct | 8687 ms | 1144 KB | Output is correct |
40 | Correct | 7550 ms | 1200 KB | Output is correct |
41 | Correct | 7466 ms | 1144 KB | Output is correct |
42 | Correct | 6912 ms | 1108 KB | Output is correct |
43 | Correct | 6299 ms | 1244 KB | Output is correct |
44 | Correct | 6318 ms | 1204 KB | Output is correct |
45 | Correct | 2335 ms | 1224 KB | Output is correct |
46 | Correct | 11 ms | 632 KB | Output is correct |
47 | Runtime error | 13 ms | 1528 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
48 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 380 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 3 ms | 376 KB | Output is correct |
27 | Correct | 53 ms | 892 KB | Output is correct |
28 | Correct | 54 ms | 1016 KB | Output is correct |
29 | Correct | 8924 ms | 1152 KB | Output is correct |
30 | Correct | 10514 ms | 1088 KB | Output is correct |
31 | Correct | 14531 ms | 1140 KB | Output is correct |
32 | Correct | 14374 ms | 1140 KB | Output is correct |
33 | Correct | 8109 ms | 1188 KB | Output is correct |
34 | Correct | 8148 ms | 1188 KB | Output is correct |
35 | Correct | 12626 ms | 1016 KB | Output is correct |
36 | Correct | 11374 ms | 1096 KB | Output is correct |
37 | Correct | 8127 ms | 1200 KB | Output is correct |
38 | Correct | 7711 ms | 1196 KB | Output is correct |
39 | Correct | 8687 ms | 1144 KB | Output is correct |
40 | Correct | 7550 ms | 1200 KB | Output is correct |
41 | Correct | 7466 ms | 1144 KB | Output is correct |
42 | Correct | 6912 ms | 1108 KB | Output is correct |
43 | Correct | 6299 ms | 1244 KB | Output is correct |
44 | Correct | 6318 ms | 1204 KB | Output is correct |
45 | Correct | 2335 ms | 1224 KB | Output is correct |
46 | Correct | 11 ms | 632 KB | Output is correct |
47 | Runtime error | 13 ms | 1528 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
48 | Halted | 0 ms | 0 KB | - |