# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
331058 | lohacho | Lamps (JOI19_lamps) | C++14 | 265 ms | 21996 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int MOD = (int)1e9 + 7;
const int NS = (int)1e6 + 4;
int N;
int A[NS], B[NS];
int dp[NS][3];
int cha(int x, int y){
if(y != 2){
return y;
}
return x;
}
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);
}
for(int i = 0; i < NS; ++i){
for(int j = 0; j < 3; ++j){
dp[i][j] = MOD;
}
}
dp[1][2] = 0;
for(int i = 1; i <= N; ++i){
for(int last = 0; last < 3; ++last){
for(int now = 0; now < 3; ++now){
int cost = 0;
if(last != now && now != 2){
++cost;
}
if((i == 1 || cha(A[i - 1], last) == B[i - 1]) && (cha(A[i], now) != B[i])){
++cost;
}
dp[i + 1][now] = min(dp[i + 1][now], cost + dp[i][last]);
}
}
}
printf("%d", min({dp[N + 1][0], dp[N + 1][1], dp[N + 1][2]}));
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... |