# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
110511 | 2019-05-11T05:06:56 Z | AngusRitossa | Lamps (JOI19_lamps) | C++14 | 1000 ms | 102008 KB |
#include <bits/stdc++.h> using namespace std; int memo[1000010][2], done[1000010][2], a[1000010], b[1000010], n; int dp(int i, int t) { if (i == n) return 0; if (done[i][t]) return memo[i][t]; done[i][t] = 1; if (a[i] == (b[i]^t)) return memo[i][t] = dp(i+1, t); int ans = dp(i+1, !t) + !t; // Remove/add a toggle, therefore curr is correct int extracost = 1, isok = 1, istoggled = t; for (int j = i; j < n; j++) { if ((b[j] == b[i]) != isok) { isok = !isok; istoggled = !istoggled; if (istoggled) extracost++; } int am = dp(j+1, istoggled)+extracost; ans = min(ans, am); } return memo[i][t] = ans; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { char c; scanf(" %c", &c); a[i] = c-'0'; } for (int i = 0; i < n; i++) { char c; scanf(" %c", &c); b[i] = c-'0'; } int ans = dp(0, 0); printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 3 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 3 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 384 KB | Output is correct |
35 | Correct | 13 ms | 512 KB | Output is correct |
36 | Correct | 14 ms | 512 KB | Output is correct |
37 | Correct | 17 ms | 512 KB | Output is correct |
38 | Correct | 24 ms | 512 KB | Output is correct |
39 | Correct | 17 ms | 512 KB | Output is correct |
40 | Correct | 19 ms | 640 KB | Output is correct |
41 | Correct | 19 ms | 512 KB | Output is correct |
42 | Correct | 17 ms | 512 KB | Output is correct |
43 | Correct | 18 ms | 512 KB | Output is correct |
44 | Correct | 20 ms | 512 KB | Output is correct |
45 | Correct | 18 ms | 512 KB | Output is correct |
46 | Correct | 17 ms | 640 KB | Output is correct |
47 | Correct | 22 ms | 512 KB | Output is correct |
48 | Correct | 26 ms | 512 KB | Output is correct |
49 | Correct | 27 ms | 512 KB | Output is correct |
50 | Correct | 32 ms | 616 KB | Output is correct |
51 | Correct | 24 ms | 512 KB | Output is correct |
52 | Correct | 25 ms | 640 KB | Output is correct |
53 | Correct | 24 ms | 512 KB | Output is correct |
54 | Correct | 24 ms | 512 KB | Output is correct |
55 | Correct | 25 ms | 512 KB | Output is correct |
56 | Correct | 24 ms | 512 KB | Output is correct |
57 | Correct | 28 ms | 512 KB | Output is correct |
58 | Correct | 25 ms | 556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 201 ms | 102008 KB | Output is correct |
8 | Execution timed out | 1078 ms | 94584 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 3 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 384 KB | Output is correct |
35 | Correct | 13 ms | 512 KB | Output is correct |
36 | Correct | 14 ms | 512 KB | Output is correct |
37 | Correct | 17 ms | 512 KB | Output is correct |
38 | Correct | 24 ms | 512 KB | Output is correct |
39 | Correct | 17 ms | 512 KB | Output is correct |
40 | Correct | 19 ms | 640 KB | Output is correct |
41 | Correct | 19 ms | 512 KB | Output is correct |
42 | Correct | 17 ms | 512 KB | Output is correct |
43 | Correct | 18 ms | 512 KB | Output is correct |
44 | Correct | 20 ms | 512 KB | Output is correct |
45 | Correct | 18 ms | 512 KB | Output is correct |
46 | Correct | 17 ms | 640 KB | Output is correct |
47 | Correct | 22 ms | 512 KB | Output is correct |
48 | Correct | 26 ms | 512 KB | Output is correct |
49 | Correct | 27 ms | 512 KB | Output is correct |
50 | Correct | 32 ms | 616 KB | Output is correct |
51 | Correct | 24 ms | 512 KB | Output is correct |
52 | Correct | 25 ms | 640 KB | Output is correct |
53 | Correct | 24 ms | 512 KB | Output is correct |
54 | Correct | 24 ms | 512 KB | Output is correct |
55 | Correct | 25 ms | 512 KB | Output is correct |
56 | Correct | 24 ms | 512 KB | Output is correct |
57 | Correct | 28 ms | 512 KB | Output is correct |
58 | Correct | 25 ms | 556 KB | Output is correct |
59 | Correct | 23 ms | 384 KB | Output is correct |
60 | Correct | 2 ms | 384 KB | Output is correct |
61 | Correct | 2 ms | 384 KB | Output is correct |
62 | Correct | 2 ms | 384 KB | Output is correct |
63 | Correct | 2 ms | 384 KB | Output is correct |
64 | Correct | 2 ms | 384 KB | Output is correct |
65 | Correct | 201 ms | 102008 KB | Output is correct |
66 | Execution timed out | 1078 ms | 94584 KB | Time limit exceeded |
67 | Halted | 0 ms | 0 KB | - |