Submission #1067193

# Submission time Handle Problem Language Result Execution time Memory
1067193 2024-08-20T12:39:27 Z Braabebo10 Lamps (JOI19_lamps) C++17
0 / 100
1 ms 600 KB
#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 time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -