| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 914497 | boris_mihov | Lamps (JOI19_lamps) | C++17 | 187 ms | 221524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
typedef long long llong;
const int MAXN = 1000000 + 10;
const int INF = 1e9;
int n;
char a[MAXN];
char b[MAXN];
int dp[MAXN][3][2];
bool bl[MAXN][3][2];
int f(int idx, int started, int flip)
{
if (idx == n + 1)
{
return 0;
}
if (bl[idx][started][flip])
{
return dp[idx][started][flip];
}
bl[idx][started][flip] = true;
if (started == b[idx] - '0')
{
return dp[idx][started][flip] = f(idx + 1, started, flip);
}
if (started != 2)
{
return dp[idx][started][flip] = f(idx, 2, flip);
}
dp[idx][started][flip] = f(idx + 1, b[idx] - '0', flip) + 1;
if (a[idx] == b[idx])
{
dp[idx][started][flip] = std::min(dp[idx][started][flip], f(idx + 1, 2, 0));
} else
{
dp[idx][started][flip] = std::min(dp[idx][started][flip], f(idx + 1, 2, 1) + !flip);
}
return dp[idx][started][flip];
}
void solve()
{
std::cout << f(1, 2, 0) << '\n';
}
void input()
{
std::cin >> n;
std::cin >> a + 1;
std::cin >> b + 1;
}
void fastIOI()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIOI();
input();
solve();
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... | ||||
