이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 1'000'010;
int dp[N][3][2];
string s, t;
int n;
void update(int i, int op, int dif)
{
int x = dp[i][0][ '0' != t[i]] + (op != 0) + (!dif && '0' != t[i]);
int y = dp[i][1][ '1' != t[i]] + (op != 1) + (!dif && '1' != t[i]);
int z = dp[i][2][s[i] != t[i]] + ( 0) + (!dif && s[i] != t[i]);
dp[i+1][op][dif] = min({x, y, z});
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n >> s >> t;
Loop (i,0,n) {
Loop (op,0,3) {
Loop (dif,0,2) {
update(i, op, dif);
}
}
}
cout << dp[n][2][0] << '\n';
}
| # | 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... |