Submission #445727

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4457272021-07-19 12:10:07egod1537Lamps (JOI19_lamps)C++14
4 / 100
23 ms8320 KiB
#include <bits/stdc++.h>
using namespace std;
int dp[1000001], sumA[4], sumB[4], mx[4];
bool prv[4];
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n; cin >> n;
string A, B; cin >> A >> B;
prv[1] = prv[3] = true;
memset(dp, 0x3f3f3f3f, sizeof(dp));
dp[0] = 0;
for (int i = 1; i <= n; i++) {
int& ret = dp[i];
if (!prv[0] && B[i-1] == '1') sumA[0]++;
if (prv[0] && B[i-1] == '0') sumB[0]++;
ret = min(ret, mx[0]+sumA[0] + 1);
prv[0] = B[i-1] == '1';
if (prv[1] && B[i-1] == '0') sumA[1]++;
if (!prv[1] && B[i-1] == '1') sumB[1]++;
ret = min(ret, mx[1] + sumA[1] + 1);
prv[1] = B[i-1] == '1';
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...