# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
204058 | ics0503 | Lamps (JOI19_lamps) | C++17 | 35 ms | 26360 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(min(D[i - 1][0], D[i - 1][1] + 1), D[i - 1][4] + 1), D[i - 1][5] + 1);
if (b[i] != '1')D[i][1] = 1e9;
else D[i][1] = min(min(min(D[i - 1][1], D[i - 1][0] + 1), D[i - 1][4] + 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;
}
컴파일 시 표준 에러 (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... |