Submission #287812

# Submission time Handle Problem Language Result Execution time Memory
287812 2020-09-01T02:33:14 Z YJU Lamps (JOI19_lamps) C++14
100 / 100
99 ms 67188 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=1e6+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,a[N],b[N],dp[N][6];
string A,B;

ll ck(ll o,ll q){
	ll qf=q/2;
	if(qf==1)o=0;else if(qf==2)o=1;
	return ((q&1)?1^o:o);
}

ll dif(ll fr,ll ba){
	ll tmp=0;
	if(fr/2!=ba/2&&fr/2!=0)++tmp;
	if(fr%2!=ba%2&&fr%2!=0)++tmp;
	return tmp;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>A>>B;
	REP1(i,n)a[i]=A[i-1]-'0',b[i]=B[i-1]-'0';
	REP(j,6)dp[0][j]=(j?INF:0);
	REP1(i,n){
		REP(j,6){
			dp[i][j]=INF;
			if(ck(a[i],j)!=b[i]){dp[i][j]=INF;continue;}
			REP(k,6){
				dp[i][j]=min(dp[i][j],dif(j,k)+dp[i-1][k]);
			}
		}
	}
	ll ans=INF;
	REP(j,6)ans=min(ans,dp[n][j]);
	cout<<ans<<"\n";
	return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 1 ms 416 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 1 ms 416 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 0 ms 384 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 1 ms 512 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 1 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 1 ms 512 KB Output is correct
54 Correct 1 ms 512 KB Output is correct
55 Correct 1 ms 456 KB Output is correct
56 Correct 1 ms 512 KB Output is correct
57 Correct 1 ms 512 KB Output is correct
58 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 81 ms 65100 KB Output is correct
8 Correct 82 ms 67020 KB Output is correct
9 Correct 84 ms 67040 KB Output is correct
10 Correct 83 ms 67020 KB Output is correct
11 Correct 83 ms 67016 KB Output is correct
12 Correct 81 ms 67012 KB Output is correct
13 Correct 82 ms 67140 KB Output is correct
14 Correct 80 ms 67020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 1 ms 416 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 0 ms 384 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 1 ms 512 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 1 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 1 ms 512 KB Output is correct
54 Correct 1 ms 512 KB Output is correct
55 Correct 1 ms 456 KB Output is correct
56 Correct 1 ms 512 KB Output is correct
57 Correct 1 ms 512 KB Output is correct
58 Correct 1 ms 512 KB Output is correct
59 Correct 0 ms 384 KB Output is correct
60 Correct 1 ms 384 KB Output is correct
61 Correct 0 ms 384 KB Output is correct
62 Correct 0 ms 384 KB Output is correct
63 Correct 1 ms 384 KB Output is correct
64 Correct 0 ms 384 KB Output is correct
65 Correct 81 ms 65100 KB Output is correct
66 Correct 82 ms 67020 KB Output is correct
67 Correct 84 ms 67040 KB Output is correct
68 Correct 83 ms 67020 KB Output is correct
69 Correct 83 ms 67016 KB Output is correct
70 Correct 81 ms 67012 KB Output is correct
71 Correct 82 ms 67140 KB Output is correct
72 Correct 80 ms 67020 KB Output is correct
73 Correct 78 ms 67020 KB Output is correct
74 Correct 86 ms 67144 KB Output is correct
75 Correct 87 ms 67016 KB Output is correct
76 Correct 81 ms 67020 KB Output is correct
77 Correct 81 ms 67144 KB Output is correct
78 Correct 82 ms 67144 KB Output is correct
79 Correct 81 ms 67020 KB Output is correct
80 Correct 81 ms 67020 KB Output is correct
81 Correct 81 ms 67016 KB Output is correct
82 Correct 82 ms 67144 KB Output is correct
83 Correct 85 ms 67020 KB Output is correct
84 Correct 91 ms 67016 KB Output is correct
85 Correct 88 ms 67012 KB Output is correct
86 Correct 87 ms 67148 KB Output is correct
87 Correct 85 ms 67020 KB Output is correct
88 Correct 86 ms 67020 KB Output is correct
89 Correct 84 ms 67012 KB Output is correct
90 Correct 99 ms 67084 KB Output is correct
91 Correct 87 ms 67016 KB Output is correct
92 Correct 89 ms 67020 KB Output is correct
93 Correct 91 ms 67020 KB Output is correct
94 Correct 91 ms 67020 KB Output is correct
95 Correct 90 ms 67020 KB Output is correct
96 Correct 89 ms 67012 KB Output is correct
97 Correct 90 ms 67020 KB Output is correct
98 Correct 89 ms 67016 KB Output is correct
99 Correct 89 ms 67188 KB Output is correct
100 Correct 89 ms 67012 KB Output is correct
101 Correct 94 ms 67148 KB Output is correct
102 Correct 89 ms 67020 KB Output is correct