# include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, pref[N][2], fl[N]; //dp[N][N][2]
string a, b;
//int calc (int l, int r, int type){
//
// if (l > r) return 0;
//
// if (dp[l][r][type] < 1e9) return dp[l][r][type];
//
// int &ans = dp[l][r][type];
//
// if (type == 0){
//
// if ( a[l] == b[l] ){
// ans = calc(l + 1, r, type);
// return ans;
// }
// if ( a[r] == b[r] ){
// ans = calc(l, r - 1, type);
// return ans;
// }
//
// ans = min(ans, pref[r][0] );
// }
//}
main(){
// memset( dp, 0x3f3f3f3f, sizeof(dp) );
cin >> n >> a >> b;
a = ' ' + a;
b = ' ' + b;
for (int i = 1; i <= n; i++){
if (i > 1 && a[i] != a[i - 1])
fl[i]++;
fl[i] += fl[i - 1];
if (b[i] != b[i - 1])
pref[i][ b[i] - 48 ] = 1;
pref[i][0] += pref[i - 1][0];
pref[i][1] += pref[i - 1][1];
}
assert(fl[n] == 0);
cout << pref[n][1] << endl;
// calc(1, n, 0);
// calc(1, n, 1);
//
// cout << min( dp[1][n][0], dp[1][n][1] ) << endl;
}
Compilation message
lamp.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
84 ms |
14068 KB |
Output is correct |
8 |
Correct |
119 ms |
14488 KB |
Output is correct |
9 |
Correct |
85 ms |
14516 KB |
Output is correct |
10 |
Correct |
85 ms |
14524 KB |
Output is correct |
11 |
Correct |
88 ms |
14524 KB |
Output is correct |
12 |
Correct |
87 ms |
14708 KB |
Output is correct |
13 |
Correct |
78 ms |
14528 KB |
Output is correct |
14 |
Correct |
83 ms |
14492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |