# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204056 | ics0503 | Lamps (JOI19_lamps) | C++17 | 36 ms | 27860 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
char a[1212121], b[1212121];
int D[1212121][6];
int min(int a, int b) { if (a < b)return a; return b; }
int main() {
int n, i, j; scanf("%d%s%s", &n,a+1,b+1);
D[0][0] = D[0][1] = D[0][2] = D[0][3] = D[0][4] = 1e9;
for (i = 1; i <= n; i++) {
if (b[i] != '0')D[i][0] = 1e9;
else D[i][0] = min(min(D[i - 1][0], D[i - 1][1] + 1), D[i - 1][5] + 1);
if (b[i] != '1')D[i][1] = 1e9;
else D[i][1] = min(min(D[i - 1][1], D[i - 1][0] + 1), D[i - 1][5] + 1);
if (b[i] != '0')D[i][2] = 1e9;
else D[i][2] = min(min(D[i - 1][2], D[i - 1][3] + 1), D[i - 1][4] + 1);
if (b[i] != '1')D[i][3] = 1e9;
else D[i][3] = min(min(D[i - 1][3], D[i - 1][2] + 1), D[i - 1][4] + 1);
if (a[i] == b[i]) D[i][4] = 1e9;
else D[i][4] = min(min(min(min(min(D[i - 1][4], D[i - 1][0] + 1), D[i - 1][1] + 1), D[i - 1][2]), D[i - 1][3]), D[i - 1][5] + 1);
if (a[i] != b[i])D[i][5] = 1e9;
else D[i][5] = min(min(min(min(min(D[i - 1][0], D[i - 1][1]), D[i - 1][2]), D[i - 1][3]), D[i - 1][4]), D[i - 1][5]);
}
printf("%d", min(min(min(min(min(D[n][0], D[n][1]), D[n][2]), D[n][3]),D[n][4]),D[n][5]));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |