Submission #967134

# Submission time Handle Problem Language Result Execution time Memory
967134 2024-04-21T09:01:49 Z ttamx Lamps (JOI19_lamps) C++17
0 / 100
2 ms 2396 KB
#include<bits/stdc++.h>

using namespace std;

const int N=1e6+5;

int n;
char a[N],b[N];
int dp[N][3][2];

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> (a+1) >> (b+1);
    for(int i=0;i<=n;i++)for(int j=0;j<3;j++)for(int k=0;k<2;k++)dp[i][j][k]=2*n;
    dp[0][0][0]=0;
    for(int i=1;i<=n;i++)for(int j=0;j<3;j++)for(int k=0;k<3;k++)for(int tl=0;tl<2;tl++)for(int tr=0;tr<2;tr++){
        if(j&&k&&j!=k)continue;
        int v=a[i]-'0';
        if(j)v=j-1;
        else if(k)v=k-1;
        v^=tl;
        if(v!=b[i]-'0')continue;
        dp[i][k][tr]=min(dp[i][k][tr],dp[i-1][j][tl]+(j!=k)+(tl!=tr));
    }
    cout << dp[n][0][0]/2;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 2 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 2 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 2 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -