Submission #653014

# Submission time Handle Problem Language Result Execution time Memory
653014 2022-10-25T12:01:48 Z ghostwriter Lamps (JOI19_lamps) C++14
0 / 100
6 ms 11988 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=1e6;
int n, dp[mxN][3]; // use 0, use 1, use nothing
string a, b;
 
int main() {
	// freopen("TEST.inp", "r", stdin);
    // freopen("BRUTE.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> a >> b;
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0]=(a[0]!=b[0]);
	dp[0][1]=1+(b[0]=='1');
	dp[0][2]=1+(b[0]=='0');
	for (int i=1; i<n; ++i) {
		for (int j=0; j<3; ++j) {
			for (int k=0; k<3; ++k) {
				int dif1=j==1?b[i-1]=='1':j==2?b[i-1]=='0':b[i-1]!=a[i-1];
				int dif2=k==1?b[i]=='1':k==2?b[i]=='0':b[i]!=a[i];
				dp[i][k]=min(dp[i][k], dp[i-1][j]+(k>0&&j!=k)+(dif2&&!dif1));
			}
		}
	}
	cout << min({dp[n-1][0], dp[n-1][1], dp[n-2][2]});
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Output is correct
2 Incorrect 6 ms 11988 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11988 KB Output isn't correct
2 Halted 0 ms 0 KB -