# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1116239 |
2024-11-21T11:27:13 Z |
firewater |
Lamps (JOI19_lamps) |
C++14 |
|
38 ms |
49392 KB |
#include<bits/stdc++.h>
#define N 1001000
using namespace std;
int n,ans,a[N],b[N],f[N][5][2];
char s1[N],s2[N];
int main()
{
scanf("%d%s%s",&n,s1+1,s2+1);
for(int i=1;i<=n;++i)
a[i]=s2[i]-'0'+1,b[i]=(s1[i]!=s2[i]);
memset(f,127/3,sizeof(f));
f[0][0][0]=0;
for(int i=1;i<=n;++i)
for(int j=0;j<=2;++j)
for(int k=0;k<=1;++k){
f[i][0][b[i]]=min(f[i][0][b[i]],f[i-1][j][k]+(b[i]&&(b[i]!=k)));
if(j)f[i][j][k]=min(f[i][j][k],f[i-1][j][k]+(a[i]!=j&&a[i]!=a[i-1]));
f[i][a[i]][k]=min(f[i][a[i]][k],f[i-1][j][k]+1);
}
ans=f[0][0][1];
for(int j=0;j<=2;++j)
for(int k=0;k<=1;++k)
ans=min(ans,f[n][j][k]);
printf("%d\n",ans);
return 0;
}
Compilation message
lamp.cpp: In function 'int main()':
lamp.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | scanf("%d%s%s",&n,s1+1,s2+1);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
43344 KB |
Output is correct |
2 |
Correct |
6 ms |
43344 KB |
Output is correct |
3 |
Correct |
5 ms |
43536 KB |
Output is correct |
4 |
Correct |
6 ms |
43344 KB |
Output is correct |
5 |
Correct |
5 ms |
43344 KB |
Output is correct |
6 |
Correct |
6 ms |
43468 KB |
Output is correct |
7 |
Correct |
7 ms |
43356 KB |
Output is correct |
8 |
Correct |
6 ms |
43700 KB |
Output is correct |
9 |
Correct |
6 ms |
43532 KB |
Output is correct |
10 |
Correct |
7 ms |
43492 KB |
Output is correct |
11 |
Correct |
6 ms |
43344 KB |
Output is correct |
12 |
Correct |
6 ms |
43456 KB |
Output is correct |
13 |
Correct |
6 ms |
43344 KB |
Output is correct |
14 |
Correct |
6 ms |
43344 KB |
Output is correct |
15 |
Correct |
6 ms |
43344 KB |
Output is correct |
16 |
Correct |
6 ms |
43344 KB |
Output is correct |
17 |
Correct |
6 ms |
43344 KB |
Output is correct |
18 |
Correct |
6 ms |
43344 KB |
Output is correct |
19 |
Correct |
6 ms |
43344 KB |
Output is correct |
20 |
Correct |
6 ms |
43532 KB |
Output is correct |
21 |
Correct |
6 ms |
43344 KB |
Output is correct |
22 |
Correct |
5 ms |
43344 KB |
Output is correct |
23 |
Correct |
6 ms |
43536 KB |
Output is correct |
24 |
Correct |
6 ms |
43344 KB |
Output is correct |
25 |
Correct |
6 ms |
43344 KB |
Output is correct |
26 |
Incorrect |
6 ms |
43344 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
43344 KB |
Output is correct |
2 |
Correct |
6 ms |
43344 KB |
Output is correct |
3 |
Correct |
5 ms |
43536 KB |
Output is correct |
4 |
Correct |
6 ms |
43344 KB |
Output is correct |
5 |
Correct |
5 ms |
43344 KB |
Output is correct |
6 |
Correct |
6 ms |
43468 KB |
Output is correct |
7 |
Correct |
7 ms |
43356 KB |
Output is correct |
8 |
Correct |
6 ms |
43700 KB |
Output is correct |
9 |
Correct |
6 ms |
43532 KB |
Output is correct |
10 |
Correct |
7 ms |
43492 KB |
Output is correct |
11 |
Correct |
6 ms |
43344 KB |
Output is correct |
12 |
Correct |
6 ms |
43456 KB |
Output is correct |
13 |
Correct |
6 ms |
43344 KB |
Output is correct |
14 |
Correct |
6 ms |
43344 KB |
Output is correct |
15 |
Correct |
6 ms |
43344 KB |
Output is correct |
16 |
Correct |
6 ms |
43344 KB |
Output is correct |
17 |
Correct |
6 ms |
43344 KB |
Output is correct |
18 |
Correct |
6 ms |
43344 KB |
Output is correct |
19 |
Correct |
6 ms |
43344 KB |
Output is correct |
20 |
Correct |
6 ms |
43532 KB |
Output is correct |
21 |
Correct |
6 ms |
43344 KB |
Output is correct |
22 |
Correct |
5 ms |
43344 KB |
Output is correct |
23 |
Correct |
6 ms |
43536 KB |
Output is correct |
24 |
Correct |
6 ms |
43344 KB |
Output is correct |
25 |
Correct |
6 ms |
43344 KB |
Output is correct |
26 |
Incorrect |
6 ms |
43344 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
43344 KB |
Output is correct |
2 |
Correct |
7 ms |
43344 KB |
Output is correct |
3 |
Correct |
6 ms |
43640 KB |
Output is correct |
4 |
Correct |
6 ms |
43344 KB |
Output is correct |
5 |
Correct |
6 ms |
43344 KB |
Output is correct |
6 |
Correct |
6 ms |
43532 KB |
Output is correct |
7 |
Correct |
33 ms |
49244 KB |
Output is correct |
8 |
Correct |
35 ms |
49232 KB |
Output is correct |
9 |
Correct |
38 ms |
49392 KB |
Output is correct |
10 |
Correct |
35 ms |
49248 KB |
Output is correct |
11 |
Correct |
37 ms |
49232 KB |
Output is correct |
12 |
Correct |
32 ms |
49232 KB |
Output is correct |
13 |
Correct |
33 ms |
49232 KB |
Output is correct |
14 |
Correct |
34 ms |
49232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
43344 KB |
Output is correct |
2 |
Correct |
6 ms |
43344 KB |
Output is correct |
3 |
Correct |
5 ms |
43536 KB |
Output is correct |
4 |
Correct |
6 ms |
43344 KB |
Output is correct |
5 |
Correct |
5 ms |
43344 KB |
Output is correct |
6 |
Correct |
6 ms |
43468 KB |
Output is correct |
7 |
Correct |
7 ms |
43356 KB |
Output is correct |
8 |
Correct |
6 ms |
43700 KB |
Output is correct |
9 |
Correct |
6 ms |
43532 KB |
Output is correct |
10 |
Correct |
7 ms |
43492 KB |
Output is correct |
11 |
Correct |
6 ms |
43344 KB |
Output is correct |
12 |
Correct |
6 ms |
43456 KB |
Output is correct |
13 |
Correct |
6 ms |
43344 KB |
Output is correct |
14 |
Correct |
6 ms |
43344 KB |
Output is correct |
15 |
Correct |
6 ms |
43344 KB |
Output is correct |
16 |
Correct |
6 ms |
43344 KB |
Output is correct |
17 |
Correct |
6 ms |
43344 KB |
Output is correct |
18 |
Correct |
6 ms |
43344 KB |
Output is correct |
19 |
Correct |
6 ms |
43344 KB |
Output is correct |
20 |
Correct |
6 ms |
43532 KB |
Output is correct |
21 |
Correct |
6 ms |
43344 KB |
Output is correct |
22 |
Correct |
5 ms |
43344 KB |
Output is correct |
23 |
Correct |
6 ms |
43536 KB |
Output is correct |
24 |
Correct |
6 ms |
43344 KB |
Output is correct |
25 |
Correct |
6 ms |
43344 KB |
Output is correct |
26 |
Incorrect |
6 ms |
43344 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |