Submission #1067193

#TimeUsernameProblemLanguageResultExecution timeMemory
1067193Braabebo10Lamps (JOI19_lamps)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> #define ll long long #define nl "\n" #define all(v) v.begin(),v.end() #define fast ios_base::sync_with_stdio(false);cin.tie(NULL); using namespace std; int main() { fast ll n; cin>>n; string a,b; cin>>a>>b; ll dp[n+10][3][2]; memset(dp,0x3f, sizeof(dp)); for(ll j=0;j<3;j++) for(ll k=0;k<2;k++) dp[n][j][k]=0; for(ll i=n-1;i>=0;i--){ for(ll j=0;j<3;j++){ for(ll k=0;k<2;k++){ ll val=a[i]-'0'; val=(j>0?j-1:val); val=(k>0?k-1:val); if(val!=(b[i]-'0'))continue; for(ll j2=0;j2<3;j2++){ for(ll k2=0;k2<2;k2++){ dp[i][j][k]=min(dp[i][j][k],dp[i+1][j2][k2]+(j>0&&j!=j2)+(k>0&&k2!=k)); } } } } } ll ans=1e18; for(ll j=0;j<3;j++) for(ll k=0;k<2;k++)ans=min(ans,dp[0][j][k]); cout<<ans; 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...