# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
364645 | parsabahrami | Lamps (JOI19_lamps) | C++17 | 78 ms | 23020 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Call my Name and Save me from The Dark
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define SZ(x) (int) x.size()
#define F first
#define S second
const int N = 1e6 + 10, MOD = 1e9 + 7;
int dp[N][3], A[N], B[N], n; char S[N];
int main() {
scanf("%d", &n);
scanf("%s", S + 1);
for (int i = 1; i <= n; i++) A[i] = S[i] - '0';
for (int i = 0; i < N; i++) dp[i][0] = dp[i][1] = dp[i][2] = MOD;
scanf("%s", S + 1);
dp[0][2] = 0;
for (int i = 1; i <= n; i++) B[i] = S[i] - '0';
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
int x = dp[i][j];
if (j != k && k != 2) x++;
int a = (j == 0 ? 0 : (j == 1 ? 1 : A[i]));
int b = (k == 0 ? 0 : (k == 1 ? 1 : A[i + 1]));
if ((!i || a == B[i]) && b != B[i + 1]) x++;
dp[i + 1][k] = min(dp[i + 1][k], x);
}
}
}
printf("%d\n", min({dp[n][0], dp[n][1], dp[n][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... |