답안 #154483

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154483 2019-09-22T04:57:49 Z username Lamps (JOI19_lamps) C++14
100 / 100
92 ms 33700 KB
#pragma GCC optimize("O3")
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
/*****************************************************************************/
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define RREP(i,j,k) for(int i=int(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define pb push_back
#define f first
#define s second
#define endl '\n'
//																#define __debug
#ifdef __debug
	#define IOS (void)0
	#define de(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
	#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
	#define de(...) (void)0
	#define ar(...) (void)0
#endif
/***********************************default***********************************/
const int maxn=1e6+9,inf=1e9;
int n,a[maxn],b[maxn],dp[maxn][2][3];

main(){
	IOS;
	cin>>n;
	REP(i,0,n){
		char c;cin>>c;
		a[i]=c-'0';
	}
	REP(i,0,n){
		char c;cin>>c;
		b[i]=c-'0';
	}
	a[n]=b[n]=0,++n;
	REP(i,0,n+1)REP(j,0,2)REP(k,0,3)dp[i][j][k]=inf;
	dp[0][0][2]=0;
	REP(i,0,n){
		REP(j,0,2){
			REP(k,0,2){
				MIN(dp[i+1][k][0],dp[i][j][2]+(!j&&k)+1);
				if(i){
					REP(l,0,2)REP(m,0,2){
						if((b[i-1]^j^b[i]^k^l^m)==0){
							MIN(dp[i+1][k][l],dp[i][j][m]+(!j&&k)+(l==1&&m==0));
						}
					}
				}
				if(a[i]==(b[i]^k))REP(l,0,3)MIN(dp[i+1][k][2],dp[i][j][l]+(!j&&k));
			}
		}
	}
	cout<<dp[n][0][2]<<endl;
}

Compilation message

lamp.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 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 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 372 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 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 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 376 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 3 ms 504 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 380 KB Output is correct
# 결과 실행 시간 메모리 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 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 372 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 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 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 376 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 3 ms 504 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 380 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 380 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 5 ms 504 KB Output is correct
44 Correct 3 ms 504 KB Output is correct
45 Correct 3 ms 504 KB Output is correct
46 Correct 3 ms 504 KB Output is correct
47 Correct 3 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 552 KB Output is correct
51 Correct 2 ms 504 KB Output is correct
52 Correct 3 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
54 Correct 2 ms 376 KB Output is correct
55 Correct 2 ms 380 KB Output is correct
56 Correct 1 ms 376 KB Output is correct
57 Correct 2 ms 504 KB Output is correct
58 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 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 74 ms 33656 KB Output is correct
8 Correct 75 ms 33656 KB Output is correct
9 Correct 76 ms 33644 KB Output is correct
10 Correct 76 ms 33628 KB Output is correct
11 Correct 75 ms 33680 KB Output is correct
12 Correct 76 ms 33568 KB Output is correct
13 Correct 76 ms 33656 KB Output is correct
14 Correct 76 ms 33656 KB Output is correct
# 결과 실행 시간 메모리 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 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 372 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 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 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 376 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 3 ms 504 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 380 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 380 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 5 ms 504 KB Output is correct
44 Correct 3 ms 504 KB Output is correct
45 Correct 3 ms 504 KB Output is correct
46 Correct 3 ms 504 KB Output is correct
47 Correct 3 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 552 KB Output is correct
51 Correct 2 ms 504 KB Output is correct
52 Correct 3 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
54 Correct 2 ms 376 KB Output is correct
55 Correct 2 ms 380 KB Output is correct
56 Correct 1 ms 376 KB Output is correct
57 Correct 2 ms 504 KB Output is correct
58 Correct 2 ms 504 KB Output is correct
59 Correct 2 ms 376 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 2 ms 376 KB Output is correct
62 Correct 2 ms 376 KB Output is correct
63 Correct 2 ms 376 KB Output is correct
64 Correct 2 ms 376 KB Output is correct
65 Correct 74 ms 33656 KB Output is correct
66 Correct 75 ms 33656 KB Output is correct
67 Correct 76 ms 33644 KB Output is correct
68 Correct 76 ms 33628 KB Output is correct
69 Correct 75 ms 33680 KB Output is correct
70 Correct 76 ms 33568 KB Output is correct
71 Correct 76 ms 33656 KB Output is correct
72 Correct 76 ms 33656 KB Output is correct
73 Correct 77 ms 33664 KB Output is correct
74 Correct 74 ms 33656 KB Output is correct
75 Correct 76 ms 33528 KB Output is correct
76 Correct 75 ms 33656 KB Output is correct
77 Correct 75 ms 33648 KB Output is correct
78 Correct 76 ms 33564 KB Output is correct
79 Correct 74 ms 33628 KB Output is correct
80 Correct 75 ms 33648 KB Output is correct
81 Correct 76 ms 33400 KB Output is correct
82 Correct 75 ms 33592 KB Output is correct
83 Correct 81 ms 33656 KB Output is correct
84 Correct 80 ms 33644 KB Output is correct
85 Correct 85 ms 33528 KB Output is correct
86 Correct 82 ms 33700 KB Output is correct
87 Correct 90 ms 33644 KB Output is correct
88 Correct 71 ms 33648 KB Output is correct
89 Correct 87 ms 33608 KB Output is correct
90 Correct 81 ms 33556 KB Output is correct
91 Correct 83 ms 33648 KB Output is correct
92 Correct 84 ms 33528 KB Output is correct
93 Correct 92 ms 33628 KB Output is correct
94 Correct 85 ms 33656 KB Output is correct
95 Correct 86 ms 33644 KB Output is correct
96 Correct 87 ms 33528 KB Output is correct
97 Correct 92 ms 33528 KB Output is correct
98 Correct 85 ms 33656 KB Output is correct
99 Correct 85 ms 33528 KB Output is correct
100 Correct 85 ms 33528 KB Output is correct
101 Correct 87 ms 33600 KB Output is correct
102 Correct 85 ms 33528 KB Output is correct