This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
cout<<i<<nl;
for(ll j=i;j<n;j++){
if(b[j]=='0')op1=false;
if(b[j]=='1')op2=false;
if(a[j]==b[j])op3=false;
else op4=false;
if(op1||op2||op3)dp[i]=min(dp[i],dp[j+1]+1);
if(op4)dp[i]=min(dp[i],dp[j+1]);
}
// cout<<dp[i]<<nl;
}
cout<<dp[0];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |