Submission #483147

# Submission time Handle Problem Language Result Execution time Memory
483147 2021-10-27T22:25:38 Z SirCovidThe19th Lamps (JOI19_lamps) C++17
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) a = min(a, b)

int n, dp[1000005][3]; string A, B;

int main(){
    cin >> n >> A >> B; A = "?" + A; B = "?" + B;
    for (int i = 1; i <= n; i++) for (int j : {0, 1, 2}){
        bool eq = (!j and A[i] == B[i]) or (j - 1 == B[i] - '0');
        int &DP = dp[i][j] = 1e9;
        MIN(DP, dp[i - 1][0] + (A[i - 1] == B[i - 1]) * !eq + (j == 1 or j == 2));
        MIN(DP, dp[i - 1][1] + (B[i - 1] == '0') * !eq + (j == 2));
        MIN(DP, dp[i - 1][2] + (B[i - 1] == '1') * !eq + (j == 1));
    }
    cout<<min({dp[n][0], dp[n][1], dp[n][2]})<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -