Submission #1066033

#TimeUsernameProblemLanguageResultExecution timeMemory
1066033AndreyLamps (JOI19_lamps)C++14
100 / 100
53 ms21980 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...