Submission #483150

#TimeUsernameProblemLanguageResultExecution timeMemory
483150SirCovidThe19thLamps (JOI19_lamps)C++17
100 / 100
83 ms14168 KiB
#include <bits/stdc++.h> using namespace std; #define MIN(a, b) a = min(a, b) int n, dp[1000005][3]; string A, B; int main(){ cin >> n >> A >> B; A = " " + A; B = " " + B; memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; for (int i = 1; i <= n; i++) for (int j : {0, 1, 2}){ bool eq = (!j and A[i] == B[i]) or (j - 1 == B[i] - '0'); int &DP = dp[i][j]; MIN(DP, dp[i - 1][0] + (j == 1 or j == 2) + (A[i - 1] == B[i - 1]) * !eq); MIN(DP, dp[i - 1][1] + (j == 2) + (B[i - 1] == '0') * !eq); MIN(DP, dp[i - 1][2] + (j == 1) + (B[i - 1] == '1') * !eq); } cout<<min({dp[n][0], dp[n][1], dp[n][2]})<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...