| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 634414 | ParsaEs | Lamps (JOI19_lamps) | C++17 | 47 ms | 15948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//InTheNameOfGOD
//PRS;)
#pragma GCC optimize("unroll-loops", "O2", "Ofast", "O3")
#pragma GCC target("avx2", "sse", "sse2")
#include <cstdio>
constexpr int MAX_N = 1000000;
int N;
char A[MAX_N + 1], B[MAX_N + 1];
/*
0: OFF
1: ON
2: KEPT
*/
char apply(char a, int y) {
return (y == 0) ? '0' : (y == 1) ? '1' : a;
}
int dp[MAX_N + 1][3];
int main() {
scanf("%d%s%s", &N, A, B);
for (int i = 0; i <= N; ++i) {
for (int x = 0; x < 3; ++x) {
dp[i][x] = N + 1;
}
}
dp[0][2] = 0;
for (int i = 0; i < N; ++i) {
for (int x = 0; x < 3; ++x) {
for (int xx = 0; xx < 3; ++xx) {
int cost = dp[i][x];
if (x != xx && xx != 2) {
++cost;
}
if ((i == 0 || apply(A[i - 1], x) == B[i - 1]) &&
apply(A[i], xx) != B[i]) {
++cost;
}
if (dp[i + 1][xx] > cost) {
dp[i + 1][xx] = cost;
}
}
}
}
int ans = N + 1;
for (int x = 0; x < 3; ++x) {
if (ans > dp[N][x]) {
ans = dp[N][x];
}
}
printf("%d\n", ans);
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... | ||||
