Submission #1001353

# Submission time Handle Problem Language Result Execution time Memory
1001353 2024-06-19T01:36:55 Z biximo Lamps (JOI19_lamps) C++17
10 / 100
37 ms 35772 KB
#include <bits/stdc++.h>
#define N 1000005
#define INF 1000000000
using namespace std;
void chmin(int& a, int v) {
	a = min(a,v);
}
/* 
0 - none
1 - flip
2 - ons
3 - offs
4 - flip, ons
5 - flip, offs
6 - ons, flip
7 - offs, flip  
*/
int n, dp[N][8];
string A, B;
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> A >> B;
    for(auto&i: dp) for(auto&j: i) j = INF;
    dp[0][0] = 0;
	for(int i = 0; i < n; i ++) {
		if(A[i] == B[i]) {
			chmin(dp[i+1][0],min({dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4],dp[i][5],dp[i][6],dp[i][7]}));
		} else {
			chmin(dp[i+1][1],min({dp[i][0]+1,dp[i][1],dp[i][4],dp[i][5],dp[i][6],dp[i][7]}));
		}

		if(B[i] == '1') {
			chmin(dp[i+1][2],min({dp[i][0]+1,dp[i][2],dp[i][4],dp[i][6]}));
			chmin(dp[i+1][6],min({dp[i][6],dp[i][1]+1}));
			chmin(dp[i+1][5],min({dp[i][5],dp[i][3]+1}));

		} else {
			chmin(dp[i+1][3],min({dp[i][0]+1,dp[i][3],dp[i][5],dp[i][7]}));
			chmin(dp[i+1][4],min({dp[i][4],dp[i][2]+1}));
			chmin(dp[i+1][7],min({dp[i][7],dp[i][1]+1}));
		}
	}
	int ans = INF;
	for(int i = 0; i < 8; i ++) {
		ans = min(ans, dp[n][i]);
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 31592 KB Output is correct
2 Correct 21 ms 31592 KB Output is correct
3 Correct 14 ms 31592 KB Output is correct
4 Correct 13 ms 31612 KB Output is correct
5 Correct 13 ms 31580 KB Output is correct
6 Correct 13 ms 31580 KB Output is correct
7 Correct 14 ms 31580 KB Output is correct
8 Correct 13 ms 31580 KB Output is correct
9 Correct 13 ms 31580 KB Output is correct
10 Correct 12 ms 31756 KB Output is correct
11 Correct 14 ms 31592 KB Output is correct
12 Correct 14 ms 31688 KB Output is correct
13 Correct 13 ms 31592 KB Output is correct
14 Correct 15 ms 31592 KB Output is correct
15 Correct 14 ms 31584 KB Output is correct
16 Correct 13 ms 31592 KB Output is correct
17 Correct 13 ms 31592 KB Output is correct
18 Correct 13 ms 31716 KB Output is correct
19 Correct 13 ms 31592 KB Output is correct
20 Correct 14 ms 31668 KB Output is correct
21 Correct 15 ms 31588 KB Output is correct
22 Correct 14 ms 31588 KB Output is correct
23 Correct 13 ms 31532 KB Output is correct
24 Correct 13 ms 31588 KB Output is correct
25 Correct 14 ms 31588 KB Output is correct
26 Correct 18 ms 31844 KB Output is correct
27 Correct 13 ms 31588 KB Output is correct
28 Correct 15 ms 31528 KB Output is correct
29 Correct 14 ms 31832 KB Output is correct
30 Correct 13 ms 31588 KB Output is correct
31 Correct 14 ms 31584 KB Output is correct
32 Correct 11 ms 31592 KB Output is correct
33 Correct 12 ms 31592 KB Output is correct
34 Correct 12 ms 31592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 31592 KB Output is correct
2 Correct 21 ms 31592 KB Output is correct
3 Correct 14 ms 31592 KB Output is correct
4 Correct 13 ms 31612 KB Output is correct
5 Correct 13 ms 31580 KB Output is correct
6 Correct 13 ms 31580 KB Output is correct
7 Correct 14 ms 31580 KB Output is correct
8 Correct 13 ms 31580 KB Output is correct
9 Correct 13 ms 31580 KB Output is correct
10 Correct 12 ms 31756 KB Output is correct
11 Correct 14 ms 31592 KB Output is correct
12 Correct 14 ms 31688 KB Output is correct
13 Correct 13 ms 31592 KB Output is correct
14 Correct 15 ms 31592 KB Output is correct
15 Correct 14 ms 31584 KB Output is correct
16 Correct 13 ms 31592 KB Output is correct
17 Correct 13 ms 31592 KB Output is correct
18 Correct 13 ms 31716 KB Output is correct
19 Correct 13 ms 31592 KB Output is correct
20 Correct 14 ms 31668 KB Output is correct
21 Correct 15 ms 31588 KB Output is correct
22 Correct 14 ms 31588 KB Output is correct
23 Correct 13 ms 31532 KB Output is correct
24 Correct 13 ms 31588 KB Output is correct
25 Correct 14 ms 31588 KB Output is correct
26 Correct 18 ms 31844 KB Output is correct
27 Correct 13 ms 31588 KB Output is correct
28 Correct 15 ms 31528 KB Output is correct
29 Correct 14 ms 31832 KB Output is correct
30 Correct 13 ms 31588 KB Output is correct
31 Correct 14 ms 31584 KB Output is correct
32 Correct 11 ms 31592 KB Output is correct
33 Correct 12 ms 31592 KB Output is correct
34 Correct 12 ms 31592 KB Output is correct
35 Correct 11 ms 31592 KB Output is correct
36 Correct 11 ms 31592 KB Output is correct
37 Correct 12 ms 31592 KB Output is correct
38 Correct 12 ms 31592 KB Output is correct
39 Correct 12 ms 31592 KB Output is correct
40 Incorrect 13 ms 31592 KB Output isn't correct
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 31592 KB Output is correct
2 Correct 11 ms 31612 KB Output is correct
3 Correct 12 ms 31592 KB Output is correct
4 Correct 20 ms 31592 KB Output is correct
5 Correct 16 ms 31592 KB Output is correct
6 Correct 12 ms 31592 KB Output is correct
7 Correct 24 ms 35724 KB Output is correct
8 Correct 25 ms 35760 KB Output is correct
9 Correct 37 ms 35764 KB Output is correct
10 Correct 27 ms 35760 KB Output is correct
11 Correct 26 ms 35772 KB Output is correct
12 Correct 24 ms 35692 KB Output is correct
13 Correct 24 ms 35760 KB Output is correct
14 Correct 25 ms 35772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 31592 KB Output is correct
2 Correct 21 ms 31592 KB Output is correct
3 Correct 14 ms 31592 KB Output is correct
4 Correct 13 ms 31612 KB Output is correct
5 Correct 13 ms 31580 KB Output is correct
6 Correct 13 ms 31580 KB Output is correct
7 Correct 14 ms 31580 KB Output is correct
8 Correct 13 ms 31580 KB Output is correct
9 Correct 13 ms 31580 KB Output is correct
10 Correct 12 ms 31756 KB Output is correct
11 Correct 14 ms 31592 KB Output is correct
12 Correct 14 ms 31688 KB Output is correct
13 Correct 13 ms 31592 KB Output is correct
14 Correct 15 ms 31592 KB Output is correct
15 Correct 14 ms 31584 KB Output is correct
16 Correct 13 ms 31592 KB Output is correct
17 Correct 13 ms 31592 KB Output is correct
18 Correct 13 ms 31716 KB Output is correct
19 Correct 13 ms 31592 KB Output is correct
20 Correct 14 ms 31668 KB Output is correct
21 Correct 15 ms 31588 KB Output is correct
22 Correct 14 ms 31588 KB Output is correct
23 Correct 13 ms 31532 KB Output is correct
24 Correct 13 ms 31588 KB Output is correct
25 Correct 14 ms 31588 KB Output is correct
26 Correct 18 ms 31844 KB Output is correct
27 Correct 13 ms 31588 KB Output is correct
28 Correct 15 ms 31528 KB Output is correct
29 Correct 14 ms 31832 KB Output is correct
30 Correct 13 ms 31588 KB Output is correct
31 Correct 14 ms 31584 KB Output is correct
32 Correct 11 ms 31592 KB Output is correct
33 Correct 12 ms 31592 KB Output is correct
34 Correct 12 ms 31592 KB Output is correct
35 Correct 11 ms 31592 KB Output is correct
36 Correct 11 ms 31592 KB Output is correct
37 Correct 12 ms 31592 KB Output is correct
38 Correct 12 ms 31592 KB Output is correct
39 Correct 12 ms 31592 KB Output is correct
40 Incorrect 13 ms 31592 KB Output isn't correct
41 Halted 0 ms 0 KB -