# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
158122 | 2019-10-15T03:18:44 Z | PeppaPig | Toll (BOI17_toll) | C++14 | 114 ms | 79480 KB |
#include <bits/stdc++.h> using namespace std; int k, n, m, q; int bl[50005][5][5][16]; int main() { fill_n(bl[0][0][0], 10005 * 5 * 5 * 16, 1e9); scanf("%d %d %d %d", &k, &n, &m, &q); for(int i = 1, a, b, c; i <= m; i++) { scanf("%d %d %d", &a, &b, &c); bl[a / k][a % k][b % k][0] = c; } for(int i = 1; i <= 15; i++) for(int a = 0; a <= n / k + 1; a++) for(int b = 0; b < k; b++) for(int c = 0; c < k; c++) for(int t = 0; t < k; t++) if(a + (1 << (i - 1)) <= n / k + 1) bl[a][b][c][i] = min(bl[a][b][c][i], bl[a][b][t][i-1] + bl[a + (1 << (i - 1))][t][c][i-1]); while(q--) { int a, b; scanf("%d %d", &a, &b); if(a / k >= b / k) { printf("-1\n"); continue; } int ans = b % k, dp[5]; for(int i = 0; i < k; i++) dp[i] = bl[a / k][a % k][i][0]; a = (a / k) + 1, b = b / k; for(int i = 15; ~i; i--) if(a + (1 << i) <= b) { int ndp[5]; fill_n(ndp, 5, 1e9); for(int x = 0; x < k; x++) for(int y = 0; y < k; y++) ndp[x] = min(ndp[x], dp[y] + bl[a][y][x][i]); for(int j = 0; j < k; j++) dp[j] = ndp[j]; a += (1 << i); } if(dp[ans] == 1e9) printf("-1\n"); else printf("%d\n", dp[ans]); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 112 ms | 79480 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 108 ms | 41088 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 15992 KB | Output is correct |
2 | Correct | 16 ms | 15992 KB | Output is correct |
3 | Correct | 16 ms | 16000 KB | Output is correct |
4 | Correct | 16 ms | 15996 KB | Output is correct |
5 | Correct | 16 ms | 15964 KB | Output is correct |
6 | Correct | 16 ms | 15992 KB | Output is correct |
7 | Correct | 17 ms | 15992 KB | Output is correct |
8 | Correct | 19 ms | 15992 KB | Output is correct |
9 | Correct | 18 ms | 15992 KB | Output is correct |
10 | Incorrect | 114 ms | 79428 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 15992 KB | Output is correct |
2 | Correct | 16 ms | 15992 KB | Output is correct |
3 | Correct | 16 ms | 16000 KB | Output is correct |
4 | Correct | 16 ms | 15996 KB | Output is correct |
5 | Correct | 16 ms | 15964 KB | Output is correct |
6 | Correct | 16 ms | 15992 KB | Output is correct |
7 | Correct | 17 ms | 15992 KB | Output is correct |
8 | Correct | 19 ms | 15992 KB | Output is correct |
9 | Correct | 18 ms | 15992 KB | Output is correct |
10 | Incorrect | 114 ms | 79428 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 112 ms | 79480 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |