# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102654 | FutymyClone | Lamps (JOI19_lamps) | C++14 | 49 ms | 31816 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, dp[N], a[N], b[N], c[N], lstb0[N], lstb1[N], lstc1[N];
string s, t;
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> s >> t; b[0] = -1;
for (int i = 0; i < n; i++) {
a[i + 1] = s[i] - '0';
b[i + 1] = t[i] - '0';
c[i + 1] = a[i + 1] ^ b[i + 1];
}
for (int i = 1; i <= n; i++) {
if (b[i] == 1) lstb1[i] = (b[i - 1] == 1 ? lstb1[i - 1] : i);
else lstb0[i] = (b[i - 1] == 0 ? lstb0[i - 1] : i);
if (c[i] == 1) lstc1[i] = (c[i - 1] == 1 ? lstc1[i - 1] : i);
}
memset(dp, 0x3f, sizeof(dp)); dp[0] = 0;
for (int i = 1; i <= n; i++) {
dp[i] = dp[i - 1] + (a[i] == b[i] ? 0 : 1);
if (lstb0[i]) dp[i] = min(dp[i], dp[lstb0[i] - 1] + 1);
if (lstb1[i]) dp[i] = min(dp[i], dp[lstb1[i] - 1] + 1);
if (lstc1[i]) dp[i] = min(dp[i], dp[lstc1[i] - 1] + 1);
# | 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... |