답안 #1030648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030648 2024-07-22T08:07:28 Z 정희우(#10958) Lamps (JOI19_lamps) C++17
100 / 100
72 ms 27988 KB
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
using lint = long long;
using intp = pair<int,int>;
using vint = vector<int>;

const int MAX_N=1000010;

int n;
char sa[MAX_N],sb[MAX_N];
int dt[MAX_N][6];
int path[4][3]={{0,1,5},{3,4,2},{3,1,5},{0,4,2}};

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> sa >> sb;
    fill(dt[0],dt[0]+MAX_N*6,MAX_N);
    dt[0][0]=0;
    for(int i=0;i<n;i++)
        for(int p=0;p<6;p++)
            for(int k=0;k<3;k++)
            {
                int p1=p%3,p2=p/3;
                int v=path[(sa[i]-'0')*2+(sb[i]-'0')][k];
                int v1=v%3,v2=v/3;
                dt[i+1][v]=min(dt[i+1][v],dt[i][p]+(p1!=v1)*(v1!=0)+(p2!=v2)*(v2!=0));
            }
    int ans=MAX_N;
    for(int p=0;p<6;p++)
        ans=min(ans,dt[n][p]);
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 23900 KB Output is correct
2 Correct 11 ms 23920 KB Output is correct
3 Correct 9 ms 23900 KB Output is correct
4 Correct 11 ms 23900 KB Output is correct
5 Correct 11 ms 23756 KB Output is correct
6 Correct 9 ms 23900 KB Output is correct
7 Correct 12 ms 23900 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23760 KB Output is correct
10 Correct 15 ms 23816 KB Output is correct
11 Correct 9 ms 23900 KB Output is correct
12 Correct 10 ms 23764 KB Output is correct
13 Correct 15 ms 23800 KB Output is correct
14 Correct 12 ms 23900 KB Output is correct
15 Correct 10 ms 23708 KB Output is correct
16 Correct 10 ms 23896 KB Output is correct
17 Correct 9 ms 23808 KB Output is correct
18 Correct 10 ms 23896 KB Output is correct
19 Correct 13 ms 23900 KB Output is correct
20 Correct 9 ms 23900 KB Output is correct
21 Correct 9 ms 23900 KB Output is correct
22 Correct 9 ms 23900 KB Output is correct
23 Correct 9 ms 23728 KB Output is correct
24 Correct 9 ms 23900 KB Output is correct
25 Correct 10 ms 23896 KB Output is correct
26 Correct 9 ms 23900 KB Output is correct
27 Correct 9 ms 23900 KB Output is correct
28 Correct 9 ms 23900 KB Output is correct
29 Correct 9 ms 23900 KB Output is correct
30 Correct 9 ms 23724 KB Output is correct
31 Correct 10 ms 23900 KB Output is correct
32 Correct 10 ms 23764 KB Output is correct
33 Correct 12 ms 23760 KB Output is correct
34 Correct 13 ms 23844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 23900 KB Output is correct
2 Correct 11 ms 23920 KB Output is correct
3 Correct 9 ms 23900 KB Output is correct
4 Correct 11 ms 23900 KB Output is correct
5 Correct 11 ms 23756 KB Output is correct
6 Correct 9 ms 23900 KB Output is correct
7 Correct 12 ms 23900 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23760 KB Output is correct
10 Correct 15 ms 23816 KB Output is correct
11 Correct 9 ms 23900 KB Output is correct
12 Correct 10 ms 23764 KB Output is correct
13 Correct 15 ms 23800 KB Output is correct
14 Correct 12 ms 23900 KB Output is correct
15 Correct 10 ms 23708 KB Output is correct
16 Correct 10 ms 23896 KB Output is correct
17 Correct 9 ms 23808 KB Output is correct
18 Correct 10 ms 23896 KB Output is correct
19 Correct 13 ms 23900 KB Output is correct
20 Correct 9 ms 23900 KB Output is correct
21 Correct 9 ms 23900 KB Output is correct
22 Correct 9 ms 23900 KB Output is correct
23 Correct 9 ms 23728 KB Output is correct
24 Correct 9 ms 23900 KB Output is correct
25 Correct 10 ms 23896 KB Output is correct
26 Correct 9 ms 23900 KB Output is correct
27 Correct 9 ms 23900 KB Output is correct
28 Correct 9 ms 23900 KB Output is correct
29 Correct 9 ms 23900 KB Output is correct
30 Correct 9 ms 23724 KB Output is correct
31 Correct 10 ms 23900 KB Output is correct
32 Correct 10 ms 23764 KB Output is correct
33 Correct 12 ms 23760 KB Output is correct
34 Correct 13 ms 23844 KB Output is correct
35 Correct 10 ms 23900 KB Output is correct
36 Correct 10 ms 23900 KB Output is correct
37 Correct 10 ms 23764 KB Output is correct
38 Correct 12 ms 23904 KB Output is correct
39 Correct 11 ms 23896 KB Output is correct
40 Correct 9 ms 23900 KB Output is correct
41 Correct 10 ms 23896 KB Output is correct
42 Correct 10 ms 23900 KB Output is correct
43 Correct 13 ms 23732 KB Output is correct
44 Correct 10 ms 23896 KB Output is correct
45 Correct 10 ms 23900 KB Output is correct
46 Correct 12 ms 23900 KB Output is correct
47 Correct 10 ms 23896 KB Output is correct
48 Correct 10 ms 23836 KB Output is correct
49 Correct 11 ms 23764 KB Output is correct
50 Correct 10 ms 23900 KB Output is correct
51 Correct 11 ms 23788 KB Output is correct
52 Correct 10 ms 23760 KB Output is correct
53 Correct 14 ms 23732 KB Output is correct
54 Correct 9 ms 23900 KB Output is correct
55 Correct 9 ms 23900 KB Output is correct
56 Correct 11 ms 23900 KB Output is correct
57 Correct 12 ms 23768 KB Output is correct
58 Correct 11 ms 23992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23900 KB Output is correct
2 Correct 10 ms 23900 KB Output is correct
3 Correct 10 ms 23900 KB Output is correct
4 Correct 10 ms 23696 KB Output is correct
5 Correct 9 ms 23900 KB Output is correct
6 Correct 10 ms 23736 KB Output is correct
7 Correct 70 ms 27760 KB Output is correct
8 Correct 67 ms 27740 KB Output is correct
9 Correct 66 ms 27736 KB Output is correct
10 Correct 71 ms 27740 KB Output is correct
11 Correct 72 ms 27836 KB Output is correct
12 Correct 67 ms 27832 KB Output is correct
13 Correct 66 ms 27740 KB Output is correct
14 Correct 65 ms 27732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 23900 KB Output is correct
2 Correct 11 ms 23920 KB Output is correct
3 Correct 9 ms 23900 KB Output is correct
4 Correct 11 ms 23900 KB Output is correct
5 Correct 11 ms 23756 KB Output is correct
6 Correct 9 ms 23900 KB Output is correct
7 Correct 12 ms 23900 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23760 KB Output is correct
10 Correct 15 ms 23816 KB Output is correct
11 Correct 9 ms 23900 KB Output is correct
12 Correct 10 ms 23764 KB Output is correct
13 Correct 15 ms 23800 KB Output is correct
14 Correct 12 ms 23900 KB Output is correct
15 Correct 10 ms 23708 KB Output is correct
16 Correct 10 ms 23896 KB Output is correct
17 Correct 9 ms 23808 KB Output is correct
18 Correct 10 ms 23896 KB Output is correct
19 Correct 13 ms 23900 KB Output is correct
20 Correct 9 ms 23900 KB Output is correct
21 Correct 9 ms 23900 KB Output is correct
22 Correct 9 ms 23900 KB Output is correct
23 Correct 9 ms 23728 KB Output is correct
24 Correct 9 ms 23900 KB Output is correct
25 Correct 10 ms 23896 KB Output is correct
26 Correct 9 ms 23900 KB Output is correct
27 Correct 9 ms 23900 KB Output is correct
28 Correct 9 ms 23900 KB Output is correct
29 Correct 9 ms 23900 KB Output is correct
30 Correct 9 ms 23724 KB Output is correct
31 Correct 10 ms 23900 KB Output is correct
32 Correct 10 ms 23764 KB Output is correct
33 Correct 12 ms 23760 KB Output is correct
34 Correct 13 ms 23844 KB Output is correct
35 Correct 10 ms 23900 KB Output is correct
36 Correct 10 ms 23900 KB Output is correct
37 Correct 10 ms 23764 KB Output is correct
38 Correct 12 ms 23904 KB Output is correct
39 Correct 11 ms 23896 KB Output is correct
40 Correct 9 ms 23900 KB Output is correct
41 Correct 10 ms 23896 KB Output is correct
42 Correct 10 ms 23900 KB Output is correct
43 Correct 13 ms 23732 KB Output is correct
44 Correct 10 ms 23896 KB Output is correct
45 Correct 10 ms 23900 KB Output is correct
46 Correct 12 ms 23900 KB Output is correct
47 Correct 10 ms 23896 KB Output is correct
48 Correct 10 ms 23836 KB Output is correct
49 Correct 11 ms 23764 KB Output is correct
50 Correct 10 ms 23900 KB Output is correct
51 Correct 11 ms 23788 KB Output is correct
52 Correct 10 ms 23760 KB Output is correct
53 Correct 14 ms 23732 KB Output is correct
54 Correct 9 ms 23900 KB Output is correct
55 Correct 9 ms 23900 KB Output is correct
56 Correct 11 ms 23900 KB Output is correct
57 Correct 12 ms 23768 KB Output is correct
58 Correct 11 ms 23992 KB Output is correct
59 Correct 11 ms 23900 KB Output is correct
60 Correct 10 ms 23900 KB Output is correct
61 Correct 10 ms 23900 KB Output is correct
62 Correct 10 ms 23696 KB Output is correct
63 Correct 9 ms 23900 KB Output is correct
64 Correct 10 ms 23736 KB Output is correct
65 Correct 70 ms 27760 KB Output is correct
66 Correct 67 ms 27740 KB Output is correct
67 Correct 66 ms 27736 KB Output is correct
68 Correct 71 ms 27740 KB Output is correct
69 Correct 72 ms 27836 KB Output is correct
70 Correct 67 ms 27832 KB Output is correct
71 Correct 66 ms 27740 KB Output is correct
72 Correct 65 ms 27732 KB Output is correct
73 Correct 66 ms 27836 KB Output is correct
74 Correct 67 ms 27732 KB Output is correct
75 Correct 66 ms 27732 KB Output is correct
76 Correct 66 ms 27732 KB Output is correct
77 Correct 64 ms 27736 KB Output is correct
78 Correct 68 ms 27832 KB Output is correct
79 Correct 70 ms 27864 KB Output is correct
80 Correct 66 ms 27736 KB Output is correct
81 Correct 65 ms 27736 KB Output is correct
82 Correct 66 ms 27716 KB Output is correct
83 Correct 66 ms 27832 KB Output is correct
84 Correct 67 ms 27836 KB Output is correct
85 Correct 68 ms 27740 KB Output is correct
86 Correct 66 ms 27736 KB Output is correct
87 Correct 66 ms 27740 KB Output is correct
88 Correct 68 ms 27840 KB Output is correct
89 Correct 71 ms 27988 KB Output is correct
90 Correct 65 ms 27740 KB Output is correct
91 Correct 66 ms 27740 KB Output is correct
92 Correct 65 ms 27728 KB Output is correct
93 Correct 65 ms 27740 KB Output is correct
94 Correct 66 ms 27736 KB Output is correct
95 Correct 66 ms 27840 KB Output is correct
96 Correct 66 ms 27740 KB Output is correct
97 Correct 69 ms 27732 KB Output is correct
98 Correct 66 ms 27732 KB Output is correct
99 Correct 71 ms 27728 KB Output is correct
100 Correct 69 ms 27852 KB Output is correct
101 Correct 65 ms 27832 KB Output is correct
102 Correct 65 ms 27740 KB Output is correct