# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1064476 |
2024-08-18T13:10:22 Z |
ThylOne |
Lamps (JOI19_lamps) |
C++14 |
|
1000 ms |
67232 KB |
//####################
//Lamps
//####################
#include <algorithm>
#include<bits/stdc++.h>
#include <utility>
using namespace std;
string A,B;
const int inf = 2*1e6;
#define pb push_back
#define SET0 1
#define SET1 2
#define FLIP 3
void dbg(vector<int> d){
for(int i:d){
if(i==SET0)cout<<"set0 ;";
if(i==SET1)cout<<"set1 ;";
if(i==FLIP)cout<<"flip ;";
}
cout<<endl;
}
bool apply(bool r,int m){
if(m==SET0)return 0;
if(m==SET1)return 1;
if(m==FLIP)return r^1;
return r;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie();
int n; cin >> n;
cin >> A >> B;
int dp[n+1][4][4];
for(int a=0;a<=3;a++)for(int b=0;b<=3;b++)dp[n][a][b]=0;
vector<pair<int,int>> t;
for(int a=0;a<=3;a++)for(int b=0;b<=3;b++)t.pb(make_pair(a,b));
for(int pos = n-1;pos>=0;pos--){
for(int i1 = 0 ; i1<= 3;i1++)
for(int i2 = 0 ; i2 <= 3;i2++){
dp[pos][i1][i2] = 2*n+1;
for(auto p:t){
bool r = A[pos]-'0';
r = apply(r,p.first);
r = apply(r,p.second);
if(r!=(bool)(B[pos]-'0'))continue;
int c=2;
if(i1==p.second && p.first==0 && i2==0){
c=0;
}else{
if(i1==p.first || p.first==0)c--;
if(i2==p.second|| p.second==0)c--;
}
dp[pos][i1][i2] = min(dp[pos][i1][i2],c+dp[pos+1][p.first][p.second]);
}
}
}
cout<<dp[0][0][0]<<endl;
return 0;
};
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 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 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
376 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 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 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
376 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
2 ms |
344 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
348 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
2 ms |
348 KB |
Output is correct |
41 |
Correct |
3 ms |
600 KB |
Output is correct |
42 |
Correct |
2 ms |
348 KB |
Output is correct |
43 |
Correct |
2 ms |
348 KB |
Output is correct |
44 |
Correct |
2 ms |
604 KB |
Output is correct |
45 |
Correct |
2 ms |
344 KB |
Output is correct |
46 |
Correct |
2 ms |
348 KB |
Output is correct |
47 |
Correct |
2 ms |
348 KB |
Output is correct |
48 |
Correct |
2 ms |
348 KB |
Output is correct |
49 |
Correct |
2 ms |
584 KB |
Output is correct |
50 |
Correct |
2 ms |
348 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
2 ms |
348 KB |
Output is correct |
53 |
Correct |
2 ms |
452 KB |
Output is correct |
54 |
Correct |
2 ms |
348 KB |
Output is correct |
55 |
Correct |
2 ms |
348 KB |
Output is correct |
56 |
Correct |
2 ms |
348 KB |
Output is correct |
57 |
Correct |
2 ms |
348 KB |
Output is correct |
58 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
744 ms |
67116 KB |
Output is correct |
8 |
Correct |
905 ms |
66976 KB |
Output is correct |
9 |
Correct |
874 ms |
67116 KB |
Output is correct |
10 |
Correct |
845 ms |
67116 KB |
Output is correct |
11 |
Correct |
943 ms |
67116 KB |
Output is correct |
12 |
Correct |
729 ms |
66976 KB |
Output is correct |
13 |
Correct |
813 ms |
66980 KB |
Output is correct |
14 |
Correct |
780 ms |
67112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
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 |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 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 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
376 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
2 ms |
344 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
348 KB |
Output is correct |
38 |
Correct |
2 ms |
348 KB |
Output is correct |
39 |
Correct |
2 ms |
348 KB |
Output is correct |
40 |
Correct |
2 ms |
348 KB |
Output is correct |
41 |
Correct |
3 ms |
600 KB |
Output is correct |
42 |
Correct |
2 ms |
348 KB |
Output is correct |
43 |
Correct |
2 ms |
348 KB |
Output is correct |
44 |
Correct |
2 ms |
604 KB |
Output is correct |
45 |
Correct |
2 ms |
344 KB |
Output is correct |
46 |
Correct |
2 ms |
348 KB |
Output is correct |
47 |
Correct |
2 ms |
348 KB |
Output is correct |
48 |
Correct |
2 ms |
348 KB |
Output is correct |
49 |
Correct |
2 ms |
584 KB |
Output is correct |
50 |
Correct |
2 ms |
348 KB |
Output is correct |
51 |
Correct |
2 ms |
348 KB |
Output is correct |
52 |
Correct |
2 ms |
348 KB |
Output is correct |
53 |
Correct |
2 ms |
452 KB |
Output is correct |
54 |
Correct |
2 ms |
348 KB |
Output is correct |
55 |
Correct |
2 ms |
348 KB |
Output is correct |
56 |
Correct |
2 ms |
348 KB |
Output is correct |
57 |
Correct |
2 ms |
348 KB |
Output is correct |
58 |
Correct |
2 ms |
348 KB |
Output is correct |
59 |
Correct |
0 ms |
348 KB |
Output is correct |
60 |
Correct |
0 ms |
348 KB |
Output is correct |
61 |
Correct |
0 ms |
348 KB |
Output is correct |
62 |
Correct |
1 ms |
600 KB |
Output is correct |
63 |
Correct |
1 ms |
344 KB |
Output is correct |
64 |
Correct |
0 ms |
348 KB |
Output is correct |
65 |
Correct |
744 ms |
67116 KB |
Output is correct |
66 |
Correct |
905 ms |
66976 KB |
Output is correct |
67 |
Correct |
874 ms |
67116 KB |
Output is correct |
68 |
Correct |
845 ms |
67116 KB |
Output is correct |
69 |
Correct |
943 ms |
67116 KB |
Output is correct |
70 |
Correct |
729 ms |
66976 KB |
Output is correct |
71 |
Correct |
813 ms |
66980 KB |
Output is correct |
72 |
Correct |
780 ms |
67112 KB |
Output is correct |
73 |
Correct |
802 ms |
67044 KB |
Output is correct |
74 |
Correct |
795 ms |
67116 KB |
Output is correct |
75 |
Correct |
759 ms |
67116 KB |
Output is correct |
76 |
Correct |
810 ms |
67116 KB |
Output is correct |
77 |
Correct |
843 ms |
67112 KB |
Output is correct |
78 |
Correct |
851 ms |
67108 KB |
Output is correct |
79 |
Correct |
826 ms |
67112 KB |
Output is correct |
80 |
Correct |
765 ms |
67108 KB |
Output is correct |
81 |
Correct |
847 ms |
67116 KB |
Output is correct |
82 |
Correct |
831 ms |
67116 KB |
Output is correct |
83 |
Correct |
953 ms |
67112 KB |
Output is correct |
84 |
Correct |
827 ms |
67232 KB |
Output is correct |
85 |
Correct |
826 ms |
67036 KB |
Output is correct |
86 |
Correct |
850 ms |
67112 KB |
Output is correct |
87 |
Correct |
892 ms |
67116 KB |
Output is correct |
88 |
Correct |
840 ms |
66976 KB |
Output is correct |
89 |
Correct |
875 ms |
67108 KB |
Output is correct |
90 |
Correct |
868 ms |
66976 KB |
Output is correct |
91 |
Correct |
881 ms |
67120 KB |
Output is correct |
92 |
Correct |
957 ms |
67112 KB |
Output is correct |
93 |
Execution timed out |
1018 ms |
67112 KB |
Time limit exceeded |
94 |
Halted |
0 ms |
0 KB |
- |