# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136472 | 2019-07-25T10:48:55 Z | sebinkim | Connect (CEOI06_connect) | C++14 | 32 ms | 17016 KB |
#include <bits/stdc++.h> using namespace std; int D[1010][9090]; char S[33][99]; int n, m; int main() { int i, j, x, y, t, k, v; scanf("%d%d\n", &n, &m); for(i=0; i<n; i++){ fgets(S[i], 88, stdin); } n /= 2; m /= 2; for(i=0; i<=n*m; i++){ for(j=0; j<(1<<n+1); j++){ D[i][j] = 1e9; } } D[0][0] = 0; for(i=0; i<n*m; i++){ x = i % n << 1 | 1; y = i / n << 1 | 1; for(j=0; j<(1<<n+1); j++){ if(S[x][y] == 'X'){ v = 1; if(!(j & 3)) k = 2; else if((j & 3) != 3) k = 1; } else{ v = 2; if((j & 3) == 3) k = 1; else if(j & 3) k = 2; else k = 5; } if(k & 1){ t = j >> 1 & ~1; D[i + 1][t] = min(D[i + 1][t], D[i][j] + (k > 1? 0 : v)); } if(k & 2){ if(S[x + 1][y] != '-'){ t = j >> 1 | 1; D[i + 1][t] = min(D[i + 1][t], D[i][j] + v); } if(S[x][y + 1] != '|'){ t = j >> 1 & ~1 | 1 << n; D[i + 1][t] = min(D[i + 1][t], D[i][j] + v); } } if(k & 4){ if(S[x + 1][y] != '-' && S[x][y + 1] != '|'){ t = j >> 1 | 1 | 1 << n; D[i + 1][t] = min(D[i + 1][t], D[i][j] + v); } } } } printf("%d\n", D[n * m][0]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 2 ms | 504 KB | Partially correct (80% score). Wrong board |
2 | Partially correct | 2 ms | 504 KB | Partially correct (80% score). Wrong board |
3 | Partially correct | 3 ms | 632 KB | Partially correct (80% score). Wrong board |
4 | Partially correct | 4 ms | 1276 KB | Partially correct (80% score). Wrong board |
5 | Incorrect | 11 ms | 5496 KB | Wrong score! (96, expected 102) |
6 | Incorrect | 3 ms | 1144 KB | Wrong score! (102, expected 112) |
7 | Partially correct | 2 ms | 888 KB | Partially correct (80% score). Wrong board |
8 | Incorrect | 3 ms | 1272 KB | Wrong score! (74, expected 94) |
9 | Incorrect | 3 ms | 1652 KB | Wrong score! (130, expected 132) |
10 | Incorrect | 4 ms | 2168 KB | Wrong score! (188, expected 208) |
11 | Partially correct | 4 ms | 1912 KB | Partially correct (80% score). Wrong board |
12 | Incorrect | 6 ms | 3192 KB | Wrong score! (258, expected 268) |
13 | Incorrect | 6 ms | 3320 KB | Wrong score! (196, expected 208) |
14 | Incorrect | 9 ms | 5112 KB | Wrong score! (458, expected 462) |
15 | Partially correct | 11 ms | 6136 KB | Partially correct (80% score). Wrong board |
16 | Partially correct | 15 ms | 8056 KB | Partially correct (80% score). Wrong board |
17 | Incorrect | 17 ms | 8952 KB | Wrong score! (232, expected 288) |
18 | Partially correct | 32 ms | 17016 KB | Partially correct (80% score). Wrong board |
19 | Incorrect | 32 ms | 17016 KB | Wrong score! (202, expected 212) |
20 | Incorrect | 31 ms | 16988 KB | Wrong score! (352, expected 374) |