# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126425 | 2019-07-07T17:22:08 Z | TadijaSebez | Lamps (JOI19_lamps) | C++11 | 452 ms | 43644 KB |
#include <bits/stdc++.h> using namespace std; const int N=1000050; const int inf=1e9+7; int dp[N][2][5]; char a[N],b[N]; int main() { int n; scanf("%i %s %s",&n,a+1,b+1); for(int i=0;i<2;i++) for(int j=0;j<5;j++) dp[0][i][j]=inf; dp[0][0][0]=0; for(int i=1;i<=n;i++) { for(int j=0;j<2;j++) { for(int k=0;k<5;k++) { int mask=min(k,3)+j*4; int now=a[i]-'0'; if(k>0 && (k&1)) now=0; else if(k>0) now=1; if(j) now^=1; dp[i][j][k]=inf; if(now==b[i]-'0') { for(int j2=0;j2<2;j2++) { for(int k2=0;k2<5;k2++) { if(k>=3 && k2>=3 && k!=k2) continue; int mask2=min(k2,3)+j2*4; int dif=__builtin_popcount(mask^(mask&mask2)); dp[i][j][k]=min(dp[i][j][k],dp[i-1][j2][k2]+dif); } } } } } } int ans=inf; for(int j=0;j<2;j++) for(int k=0;k<5;k++) ans=min(ans,dp[n][j][k]); printf("%i\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 252 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 372 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 2 ms | 376 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 252 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 372 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 2 ms | 376 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 2 ms | 376 KB | Output is correct |
35 | Correct | 3 ms | 376 KB | Output is correct |
36 | Correct | 2 ms | 376 KB | Output is correct |
37 | Correct | 3 ms | 376 KB | Output is correct |
38 | Correct | 3 ms | 376 KB | Output is correct |
39 | Correct | 3 ms | 376 KB | Output is correct |
40 | Correct | 3 ms | 376 KB | Output is correct |
41 | Correct | 3 ms | 504 KB | Output is correct |
42 | Correct | 3 ms | 376 KB | Output is correct |
43 | Correct | 3 ms | 376 KB | Output is correct |
44 | Correct | 3 ms | 504 KB | Output is correct |
45 | Correct | 3 ms | 376 KB | Output is correct |
46 | Correct | 3 ms | 376 KB | Output is correct |
47 | Correct | 3 ms | 376 KB | Output is correct |
48 | Correct | 3 ms | 376 KB | Output is correct |
49 | Correct | 3 ms | 376 KB | Output is correct |
50 | Correct | 3 ms | 376 KB | Output is correct |
51 | Correct | 3 ms | 376 KB | Output is correct |
52 | Correct | 3 ms | 376 KB | Output is correct |
53 | Correct | 3 ms | 376 KB | Output is correct |
54 | Correct | 2 ms | 376 KB | Output is correct |
55 | Correct | 3 ms | 376 KB | Output is correct |
56 | Correct | 3 ms | 504 KB | Output is correct |
57 | Correct | 3 ms | 376 KB | Output is correct |
58 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 342 ms | 41436 KB | Output is correct |
8 | Correct | 341 ms | 41472 KB | Output is correct |
9 | Correct | 343 ms | 41464 KB | Output is correct |
10 | Correct | 343 ms | 41464 KB | Output is correct |
11 | Correct | 342 ms | 41452 KB | Output is correct |
12 | Correct | 348 ms | 41336 KB | Output is correct |
13 | Correct | 346 ms | 41432 KB | Output is correct |
14 | Correct | 348 ms | 41464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 252 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 372 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 2 ms | 376 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 2 ms | 376 KB | Output is correct |
35 | Correct | 3 ms | 376 KB | Output is correct |
36 | Correct | 2 ms | 376 KB | Output is correct |
37 | Correct | 3 ms | 376 KB | Output is correct |
38 | Correct | 3 ms | 376 KB | Output is correct |
39 | Correct | 3 ms | 376 KB | Output is correct |
40 | Correct | 3 ms | 376 KB | Output is correct |
41 | Correct | 3 ms | 504 KB | Output is correct |
42 | Correct | 3 ms | 376 KB | Output is correct |
43 | Correct | 3 ms | 376 KB | Output is correct |
44 | Correct | 3 ms | 504 KB | Output is correct |
45 | Correct | 3 ms | 376 KB | Output is correct |
46 | Correct | 3 ms | 376 KB | Output is correct |
47 | Correct | 3 ms | 376 KB | Output is correct |
48 | Correct | 3 ms | 376 KB | Output is correct |
49 | Correct | 3 ms | 376 KB | Output is correct |
50 | Correct | 3 ms | 376 KB | Output is correct |
51 | Correct | 3 ms | 376 KB | Output is correct |
52 | Correct | 3 ms | 376 KB | Output is correct |
53 | Correct | 3 ms | 376 KB | Output is correct |
54 | Correct | 2 ms | 376 KB | Output is correct |
55 | Correct | 3 ms | 376 KB | Output is correct |
56 | Correct | 3 ms | 504 KB | Output is correct |
57 | Correct | 3 ms | 376 KB | Output is correct |
58 | Correct | 3 ms | 376 KB | Output is correct |
59 | Correct | 2 ms | 256 KB | Output is correct |
60 | Correct | 2 ms | 376 KB | Output is correct |
61 | Correct | 2 ms | 256 KB | Output is correct |
62 | Correct | 2 ms | 256 KB | Output is correct |
63 | Correct | 2 ms | 376 KB | Output is correct |
64 | Correct | 2 ms | 376 KB | Output is correct |
65 | Correct | 342 ms | 41436 KB | Output is correct |
66 | Correct | 341 ms | 41472 KB | Output is correct |
67 | Correct | 343 ms | 41464 KB | Output is correct |
68 | Correct | 343 ms | 41464 KB | Output is correct |
69 | Correct | 342 ms | 41452 KB | Output is correct |
70 | Correct | 348 ms | 41336 KB | Output is correct |
71 | Correct | 346 ms | 41432 KB | Output is correct |
72 | Correct | 348 ms | 41464 KB | Output is correct |
73 | Correct | 349 ms | 43416 KB | Output is correct |
74 | Correct | 359 ms | 43428 KB | Output is correct |
75 | Correct | 345 ms | 43384 KB | Output is correct |
76 | Correct | 353 ms | 43384 KB | Output is correct |
77 | Correct | 342 ms | 43644 KB | Output is correct |
78 | Correct | 344 ms | 43384 KB | Output is correct |
79 | Correct | 340 ms | 43384 KB | Output is correct |
80 | Correct | 343 ms | 43512 KB | Output is correct |
81 | Correct | 344 ms | 43388 KB | Output is correct |
82 | Correct | 351 ms | 43464 KB | Output is correct |
83 | Correct | 353 ms | 43332 KB | Output is correct |
84 | Correct | 359 ms | 43480 KB | Output is correct |
85 | Correct | 351 ms | 43384 KB | Output is correct |
86 | Correct | 353 ms | 43504 KB | Output is correct |
87 | Correct | 352 ms | 43512 KB | Output is correct |
88 | Correct | 358 ms | 43356 KB | Output is correct |
89 | Correct | 355 ms | 43428 KB | Output is correct |
90 | Correct | 356 ms | 43512 KB | Output is correct |
91 | Correct | 360 ms | 43356 KB | Output is correct |
92 | Correct | 355 ms | 43288 KB | Output is correct |
93 | Correct | 362 ms | 43512 KB | Output is correct |
94 | Correct | 356 ms | 43376 KB | Output is correct |
95 | Correct | 356 ms | 43384 KB | Output is correct |
96 | Correct | 356 ms | 43508 KB | Output is correct |
97 | Correct | 357 ms | 43392 KB | Output is correct |
98 | Correct | 357 ms | 43512 KB | Output is correct |
99 | Correct | 358 ms | 43340 KB | Output is correct |
100 | Correct | 452 ms | 43512 KB | Output is correct |
101 | Correct | 357 ms | 43512 KB | Output is correct |
102 | Correct | 361 ms | 43416 KB | Output is correct |