# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
216809 | PeppaPig | Lamps (JOI19_lamps) | C++14 | 195 ms | 121848 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
int n, dp[N][3][2];
char A[N], B[N];
int solve(int i, int md, int f) {
if(i == n + 1) return 0;
int &now = dp[i][md][f];
if(~now) return now;
now = 1e9;
for(int x = 0; x < 3; x++) for(int y = 0; y < 2; y++) {
int cost = (x != md && x) + (y != f && y);
int cur = !x ? A[i] - '0' : x - 1;
if((cur ^ y) == B[i] - '0')
now = min(now, solve(i + 1, x, y) + cost);
}
return now;
}
int main() {
memset(dp, -1, sizeof dp);
scanf("%d %s %s", &n, A + 1, B + 1);
printf("%d\n", solve(1, 0, 0));
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... |