Submission #937546

# Submission time Handle Problem Language Result Execution time Memory
937546 2024-03-04T08:21:51 Z WonderfulWhale Lamps (JOI19_lamps) C++17
4 / 100
195 ms 67124 KB
#include<bits/stdc++.h>
using namespace std;

#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

int dp[1000009][8];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


	int n;
	cin >> n;
	for(int i=0;i<=n;i++) {
		for(int j=0;j<8;j++) {
			dp[i][j] = 1e9;
		}
	}
	dp[0][0] = 0;
	string A, B;
	cin >> A >> B;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<8;j++) {
			for(int k=0;k<8;k++) {
				bool a = k&1;
				bool b = k&2;
				bool c = k&4;
				if(a&&b) continue;
				int New = A[i-1]-'0';
				if(c) New = 1-New;
				if(a) New = 1;
				if(b) New = 0;
				if(New!=B[i-1]-'0') continue;
				bool ap = a&(!(j&1));
				bool bp = b&(!(j&2));
				bool cp = c&(!(j&4));
				dp[i][k] = min(dp[i][k], dp[i-1][j]+ap+bp+cp);
			}
		}
	}
	int ans = 1e9;
	for(int i=0;i<8;i++)
		ans = min(ans, dp[n][i]);
cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 720 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 720 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 173 ms 67052 KB Output is correct
8 Correct 161 ms 67052 KB Output is correct
9 Correct 160 ms 67016 KB Output is correct
10 Correct 161 ms 67124 KB Output is correct
11 Correct 160 ms 67120 KB Output is correct
12 Correct 164 ms 67116 KB Output is correct
13 Correct 195 ms 67060 KB Output is correct
14 Correct 161 ms 67064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 720 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -