이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int dp[1000010][3];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector<int> haha(n+2);
vector<int> bruh(n+2);
for(int i = 1; i <= n; i++) {
char a;
cin >> a;
haha[i] = a-'0';
}
for(int i = 1; i <= n; i++) {
char a;
cin >> a;
bruh[i] = a-'0';
}
dp[0][0] = 1e9;
dp[0][1] = 1e9;
dp[0][2] = 0;
for(int i = 1; i <= n+1; i++) {
dp[i][0] = 1e9;
dp[i][1] = 1e9;
dp[i][2] = 1e9;
for(int j = 0; j < 3; j++) {
for(int k = 0; k < 3; k++) {
int a = haha[i-1],b = haha[i],br = dp[i-1][j];
if(j < 2) {
a = j;
}
if(k < 2) {
b = k;
}
if((a == bruh[i-1]) != (b == bruh[i])) {
br++;
}
if(j != k) {
if(j == 2 || k == 2) {
br++;
}
else {
br+=2;
}
}
dp[i][k] = min(dp[i][k],br);
}
}
}
cout << dp[n+1][2]/2;
return 0;
}
| # | 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... |