# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
534463 | 2022-03-08T07:35:04 Z | 79brue | Lamps (JOI19_lamps) | C++14 | 133 ms | 8156 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; bool a[1000002]; bool b[1000002]; int DP[1000002]; int main(){ scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%1d", &a[i]); for(int i=1; i<=n; i++) scanf("%1d", &b[i]); int zero = 0, one = 0, rev = 0; for(int i=1; i<=n; i++){ DP[i] = 1e9; if(a[i] == b[i]) DP[i] = DP[i-1]; if(b[i] == 0){ DP[i] = min(DP[i], DP[zero] + 1); } else zero = i; if(b[i] == 1){ DP[i] = min(DP[i], DP[one] + 1); } else one = i; if(a[i] != b[i]){ DP[i] = min(DP[i], DP[rev] + 1); } else rev = i; } printf("%d", DP[n]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 296 KB | Output is correct |
13 | Incorrect | 1 ms | 300 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 296 KB | Output is correct |
13 | Incorrect | 1 ms | 300 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 123 ms | 7988 KB | Output is correct |
8 | Correct | 131 ms | 7988 KB | Output is correct |
9 | Correct | 132 ms | 8156 KB | Output is correct |
10 | Correct | 129 ms | 8004 KB | Output is correct |
11 | Correct | 133 ms | 8052 KB | Output is correct |
12 | Correct | 119 ms | 7992 KB | Output is correct |
13 | Correct | 123 ms | 8060 KB | Output is correct |
14 | Correct | 128 ms | 8132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 300 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 300 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 296 KB | Output is correct |
13 | Incorrect | 1 ms | 300 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |