Submission #1067110

#TimeUsernameProblemLanguageResultExecution timeMemory
1067110Braabebo10Lamps (JOI19_lamps)C++17
0 / 100
1 ms348 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; string a,b; cin>>n>>a>>b; ll dp[n+1]={}; memset(dp,0x3f, sizeof(dp)); dp[n]=0; for(ll i=n-1;i>=0;i--){ bool op1=true,op2=true,op3=true,op4=true; for(ll j=i;j<n;j++){ if(a[j]=='1'&&b[j]=='0')op1=false; if(a[j]=='0'&&b[j]=='1')op2=false; if(a[j]==b[j])op3=false; else op4=false; if(op1||op2||op3||op4)dp[i]=min(dp[i],dp[j+1]+1); } } cout<<dp[0]; 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...