답안 #122590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122590 2019-06-28T16:34:40 Z MvC Lamps (JOI19_lamps) C++11
100 / 100
196 ms 27900 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "rail.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e6+50;
const int mod=1e9+7;
using namespace std;
int n,i,j,t,x,y,rs=1e9,f[nmax][3][2],cs;
char c,a[nmax],b[nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>(a+1)>>(b+1);
	for(i=0;i<=n;i++)for(j=0;j<3;j++)for(t=0;t<2;t++)f[i][j][t]=1e9;
	f[0][0][0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<3;j++)
		{
			for(t=0;t<2;t++)
			{
				for(x=0;x<3;x++)
				{
					for(y=0;y<2;y++)
					{
						c=a[i];
						cs=0;
						if(x==1)c='0';
						else if(x==2)c='1';
						if(y)c='0'+'1'-c;
						if(x!=j && x)cs++;
						if(y!=t && y)cs++;
						if(c==b[i])f[i][x][y]=min(f[i][x][y],f[i-1][j][t]+cs);
					}
				}
			}
		}
	}
	for(j=0;j<3;j++)for(t=0;t<2;t++)rs=min(rs,f[n][j][t]);
	cout<<rs<<endl;
    return 0;
}

Compilation message

lamp.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
lamp.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 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 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 2 ms 392 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 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 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 2 ms 392 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 2 ms 428 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 2 ms 384 KB Output is correct
55 Correct 2 ms 356 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 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 384 KB Output is correct
7 Correct 92 ms 27812 KB Output is correct
8 Correct 93 ms 27776 KB Output is correct
9 Correct 93 ms 27808 KB Output is correct
10 Correct 97 ms 27796 KB Output is correct
11 Correct 95 ms 27772 KB Output is correct
12 Correct 99 ms 27768 KB Output is correct
13 Correct 110 ms 27768 KB Output is correct
14 Correct 104 ms 27772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 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 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 2 ms 392 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 2 ms 428 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 2 ms 384 KB Output is correct
55 Correct 2 ms 356 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 3 ms 384 KB Output is correct
59 Correct 2 ms 384 KB Output is correct
60 Correct 2 ms 384 KB Output is correct
61 Correct 2 ms 384 KB Output is correct
62 Correct 2 ms 384 KB Output is correct
63 Correct 2 ms 384 KB Output is correct
64 Correct 2 ms 384 KB Output is correct
65 Correct 92 ms 27812 KB Output is correct
66 Correct 93 ms 27776 KB Output is correct
67 Correct 93 ms 27808 KB Output is correct
68 Correct 97 ms 27796 KB Output is correct
69 Correct 95 ms 27772 KB Output is correct
70 Correct 99 ms 27768 KB Output is correct
71 Correct 110 ms 27768 KB Output is correct
72 Correct 104 ms 27772 KB Output is correct
73 Correct 99 ms 27772 KB Output is correct
74 Correct 96 ms 27868 KB Output is correct
75 Correct 102 ms 27776 KB Output is correct
76 Correct 104 ms 27776 KB Output is correct
77 Correct 98 ms 27776 KB Output is correct
78 Correct 94 ms 27720 KB Output is correct
79 Correct 108 ms 27772 KB Output is correct
80 Correct 93 ms 27768 KB Output is correct
81 Correct 92 ms 27776 KB Output is correct
82 Correct 93 ms 27768 KB Output is correct
83 Correct 97 ms 27800 KB Output is correct
84 Correct 196 ms 27868 KB Output is correct
85 Correct 101 ms 27772 KB Output is correct
86 Correct 99 ms 27768 KB Output is correct
87 Correct 108 ms 27744 KB Output is correct
88 Correct 105 ms 27800 KB Output is correct
89 Correct 126 ms 27768 KB Output is correct
90 Correct 112 ms 27768 KB Output is correct
91 Correct 112 ms 27896 KB Output is correct
92 Correct 113 ms 27768 KB Output is correct
93 Correct 110 ms 27776 KB Output is correct
94 Correct 110 ms 27768 KB Output is correct
95 Correct 110 ms 27900 KB Output is correct
96 Correct 115 ms 27740 KB Output is correct
97 Correct 108 ms 27768 KB Output is correct
98 Correct 104 ms 27768 KB Output is correct
99 Correct 105 ms 27776 KB Output is correct
100 Correct 106 ms 27896 KB Output is correct
101 Correct 103 ms 27792 KB Output is correct
102 Correct 104 ms 27868 KB Output is correct