# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
329729 | Rainbowbunny | Lamps (JOI19_lamps) | C++17 | 118 ms | 35888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
string c, d;
int cost[6][6];
int a[1000005], b[1000005];
int dp[1000005][6];
int ans = 1e9;
int main()
{
for(int i = 0; i < 6; i++)
{
for(int j = 0; j < 6; j++)
{
if(i / 2 != j / 2 && j / 2 != 0)
{
++cost[i][j];
}
if(i % 2 != j % 2 && j % 2 != 0)
{
++cost[i][j];
}
}
}
cin >> n >> c >> d;
for(int i = 1; i <= n; i++)
{
a[i] = c[i - 1] - '0';
b[i] = d[i - 1] - '0';
}
for(int i = 1; i <= 5; i++)
{
dp[0][i] = 1e9;
}
for(int i = 1; i <= n; i++)
{
for(int j = 0; j < 6; j++)
{
dp[i][j] = 1e9;
int cur = a[i];
if(j / 2 == 1)
{
cur = 0;
}
else if(j / 2 == 2)
{
cur = 1;
}
if(cur ^ (j & 1) == b[i])
{
for(int k = 0; k < 6; k++)
{
dp[i][j] = min(dp[i][j], dp[i - 1][k] + cost[k][j]);
}
}
}
}
for(int i = 0; i < 6; i++)
{
ans = min(ans, dp[n][i]);
}
cout << ans;
}
컴파일 시 표준 에러 (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... |