Submission #869603

#TimeUsernameProblemLanguageResultExecution timeMemory
86960312345678Lamps (JOI19_lamps)C++17
4 / 100
14 ms19600 KiB
#include <bits/stdc++.h> using namespace std; const int nx=1e6+5; int dp[nx][4], n; string a, b; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>a>>b; dp[0][1]=dp[0][2]=dp[0][3]=INT_MAX; for (int i=1; i<=n; i++) { dp[i][0]=dp[i][1]=dp[i][2]=dp[i][3]=INT_MAX; int mn=min({dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3]}); if (a[i-1]==b[i-1]) dp[i][0]=mn; if (b[i-1]=='1') dp[i][1]=min(dp[i-1][1], mn+1); if (b[i-1]=='0') dp[i][2]=min(dp[i-1][2], mn+1); if (a[i-1]!=b[i-1]) dp[i][3]=min(dp[i-1][3], mn+1); } cout<<min({dp[n][0], dp[n][1], dp[n][2], dp[n][3]}); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...