Submission #157020

# Submission time Handle Problem Language Result Execution time Memory
157020 2019-10-09T06:09:08 Z EntityIT Lamps (JOI19_lamps) C++14
100 / 100
131 ms 26104 KB
#include<bits/stdc++.h>

using namespace std;

const int N = (int)1e6 + 5, inf = (int)1e9 + 123;
int n, f[N][3][2];
char a[N], b[N];

int main() {
    scanf(" %d %s %s", &n, a + 1, b + 1);

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 2; ++k) f[i][j][k] = inf;
        }
    }
    f[0][0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 2; ++k) if (f[i][j][k] < inf) {
                for (int nJ = 0; nJ < 3; ++nJ) {
                    for (int nK = 0; nK < 2; ++nK) {
                        char after = a[i + 1];
                        if (nJ == 1) after = '0';
                        else if (nJ == 2) after = '1';
                        if (nK) after = (after == '0' ? '1' : '0');
                        if (after != b[i + 1]) continue ;
                        f[i + 1][nJ][nK] = min(f[i + 1][nJ][nK], f[i][j][k] + (nJ && j != nJ) + (nK && k != nK) );
                    }
                }
            }
        }
    }

    int ans = inf;
    for (int j = 0; j < 3; ++j) {
        for (int k = 0; k < 2; ++k) ans = min(ans, f[n][j][k]);
    }

    printf("%d", ans);

    return 0;
}

Compilation message

lamp.cpp: In function 'int main()':
lamp.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %d %s %s", &n, a + 1, b + 1);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 26 ms 23800 KB Output is correct
2 Correct 26 ms 23800 KB Output is correct
3 Correct 23 ms 23800 KB Output is correct
4 Correct 26 ms 23800 KB Output is correct
5 Correct 23 ms 23772 KB Output is correct
6 Correct 22 ms 23800 KB Output is correct
7 Correct 23 ms 23848 KB Output is correct
8 Correct 23 ms 23804 KB Output is correct
9 Correct 23 ms 23800 KB Output is correct
10 Correct 22 ms 23800 KB Output is correct
11 Correct 22 ms 23800 KB Output is correct
12 Correct 23 ms 23928 KB Output is correct
13 Correct 23 ms 23800 KB Output is correct
14 Correct 23 ms 23800 KB Output is correct
15 Correct 22 ms 23800 KB Output is correct
16 Correct 23 ms 23800 KB Output is correct
17 Correct 22 ms 23804 KB Output is correct
18 Correct 22 ms 23800 KB Output is correct
19 Correct 23 ms 23800 KB Output is correct
20 Correct 22 ms 23928 KB Output is correct
21 Correct 22 ms 23800 KB Output is correct
22 Correct 22 ms 23800 KB Output is correct
23 Correct 22 ms 23800 KB Output is correct
24 Correct 22 ms 23800 KB Output is correct
25 Correct 22 ms 23800 KB Output is correct
26 Correct 22 ms 23800 KB Output is correct
27 Correct 23 ms 23800 KB Output is correct
28 Correct 23 ms 23800 KB Output is correct
29 Correct 23 ms 23800 KB Output is correct
30 Correct 22 ms 23784 KB Output is correct
31 Correct 23 ms 23804 KB Output is correct
32 Correct 22 ms 23816 KB Output is correct
33 Correct 22 ms 23800 KB Output is correct
34 Correct 23 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 23800 KB Output is correct
2 Correct 26 ms 23800 KB Output is correct
3 Correct 23 ms 23800 KB Output is correct
4 Correct 26 ms 23800 KB Output is correct
5 Correct 23 ms 23772 KB Output is correct
6 Correct 22 ms 23800 KB Output is correct
7 Correct 23 ms 23848 KB Output is correct
8 Correct 23 ms 23804 KB Output is correct
9 Correct 23 ms 23800 KB Output is correct
10 Correct 22 ms 23800 KB Output is correct
11 Correct 22 ms 23800 KB Output is correct
12 Correct 23 ms 23928 KB Output is correct
13 Correct 23 ms 23800 KB Output is correct
14 Correct 23 ms 23800 KB Output is correct
15 Correct 22 ms 23800 KB Output is correct
16 Correct 23 ms 23800 KB Output is correct
17 Correct 22 ms 23804 KB Output is correct
18 Correct 22 ms 23800 KB Output is correct
19 Correct 23 ms 23800 KB Output is correct
20 Correct 22 ms 23928 KB Output is correct
21 Correct 22 ms 23800 KB Output is correct
22 Correct 22 ms 23800 KB Output is correct
23 Correct 22 ms 23800 KB Output is correct
24 Correct 22 ms 23800 KB Output is correct
25 Correct 22 ms 23800 KB Output is correct
26 Correct 22 ms 23800 KB Output is correct
27 Correct 23 ms 23800 KB Output is correct
28 Correct 23 ms 23800 KB Output is correct
29 Correct 23 ms 23800 KB Output is correct
30 Correct 22 ms 23784 KB Output is correct
31 Correct 23 ms 23804 KB Output is correct
32 Correct 22 ms 23816 KB Output is correct
33 Correct 22 ms 23800 KB Output is correct
34 Correct 23 ms 23800 KB Output is correct
35 Correct 23 ms 23920 KB Output is correct
36 Correct 26 ms 23800 KB Output is correct
37 Correct 23 ms 23800 KB Output is correct
38 Correct 26 ms 23800 KB Output is correct
39 Correct 23 ms 23928 KB Output is correct
40 Correct 22 ms 23800 KB Output is correct
41 Correct 23 ms 23800 KB Output is correct
42 Correct 23 ms 23800 KB Output is correct
43 Correct 22 ms 23800 KB Output is correct
44 Correct 23 ms 23788 KB Output is correct
45 Correct 22 ms 23800 KB Output is correct
46 Correct 23 ms 23800 KB Output is correct
47 Correct 22 ms 23800 KB Output is correct
48 Correct 22 ms 23768 KB Output is correct
49 Correct 22 ms 23800 KB Output is correct
50 Correct 22 ms 23928 KB Output is correct
51 Correct 22 ms 23800 KB Output is correct
52 Correct 23 ms 23800 KB Output is correct
53 Correct 22 ms 23800 KB Output is correct
54 Correct 22 ms 23800 KB Output is correct
55 Correct 22 ms 23800 KB Output is correct
56 Correct 22 ms 23800 KB Output is correct
57 Correct 22 ms 23800 KB Output is correct
58 Correct 23 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 23800 KB Output is correct
2 Correct 22 ms 23800 KB Output is correct
3 Correct 23 ms 23800 KB Output is correct
4 Correct 22 ms 23800 KB Output is correct
5 Correct 22 ms 23928 KB Output is correct
6 Correct 22 ms 23800 KB Output is correct
7 Correct 117 ms 25976 KB Output is correct
8 Correct 119 ms 26104 KB Output is correct
9 Correct 119 ms 26060 KB Output is correct
10 Correct 120 ms 25976 KB Output is correct
11 Correct 119 ms 25976 KB Output is correct
12 Correct 114 ms 25976 KB Output is correct
13 Correct 115 ms 25976 KB Output is correct
14 Correct 116 ms 25928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 23800 KB Output is correct
2 Correct 26 ms 23800 KB Output is correct
3 Correct 23 ms 23800 KB Output is correct
4 Correct 26 ms 23800 KB Output is correct
5 Correct 23 ms 23772 KB Output is correct
6 Correct 22 ms 23800 KB Output is correct
7 Correct 23 ms 23848 KB Output is correct
8 Correct 23 ms 23804 KB Output is correct
9 Correct 23 ms 23800 KB Output is correct
10 Correct 22 ms 23800 KB Output is correct
11 Correct 22 ms 23800 KB Output is correct
12 Correct 23 ms 23928 KB Output is correct
13 Correct 23 ms 23800 KB Output is correct
14 Correct 23 ms 23800 KB Output is correct
15 Correct 22 ms 23800 KB Output is correct
16 Correct 23 ms 23800 KB Output is correct
17 Correct 22 ms 23804 KB Output is correct
18 Correct 22 ms 23800 KB Output is correct
19 Correct 23 ms 23800 KB Output is correct
20 Correct 22 ms 23928 KB Output is correct
21 Correct 22 ms 23800 KB Output is correct
22 Correct 22 ms 23800 KB Output is correct
23 Correct 22 ms 23800 KB Output is correct
24 Correct 22 ms 23800 KB Output is correct
25 Correct 22 ms 23800 KB Output is correct
26 Correct 22 ms 23800 KB Output is correct
27 Correct 23 ms 23800 KB Output is correct
28 Correct 23 ms 23800 KB Output is correct
29 Correct 23 ms 23800 KB Output is correct
30 Correct 22 ms 23784 KB Output is correct
31 Correct 23 ms 23804 KB Output is correct
32 Correct 22 ms 23816 KB Output is correct
33 Correct 22 ms 23800 KB Output is correct
34 Correct 23 ms 23800 KB Output is correct
35 Correct 23 ms 23920 KB Output is correct
36 Correct 26 ms 23800 KB Output is correct
37 Correct 23 ms 23800 KB Output is correct
38 Correct 26 ms 23800 KB Output is correct
39 Correct 23 ms 23928 KB Output is correct
40 Correct 22 ms 23800 KB Output is correct
41 Correct 23 ms 23800 KB Output is correct
42 Correct 23 ms 23800 KB Output is correct
43 Correct 22 ms 23800 KB Output is correct
44 Correct 23 ms 23788 KB Output is correct
45 Correct 22 ms 23800 KB Output is correct
46 Correct 23 ms 23800 KB Output is correct
47 Correct 22 ms 23800 KB Output is correct
48 Correct 22 ms 23768 KB Output is correct
49 Correct 22 ms 23800 KB Output is correct
50 Correct 22 ms 23928 KB Output is correct
51 Correct 22 ms 23800 KB Output is correct
52 Correct 23 ms 23800 KB Output is correct
53 Correct 22 ms 23800 KB Output is correct
54 Correct 22 ms 23800 KB Output is correct
55 Correct 22 ms 23800 KB Output is correct
56 Correct 22 ms 23800 KB Output is correct
57 Correct 22 ms 23800 KB Output is correct
58 Correct 23 ms 23800 KB Output is correct
59 Correct 22 ms 23800 KB Output is correct
60 Correct 22 ms 23800 KB Output is correct
61 Correct 23 ms 23800 KB Output is correct
62 Correct 22 ms 23800 KB Output is correct
63 Correct 22 ms 23928 KB Output is correct
64 Correct 22 ms 23800 KB Output is correct
65 Correct 117 ms 25976 KB Output is correct
66 Correct 119 ms 26104 KB Output is correct
67 Correct 119 ms 26060 KB Output is correct
68 Correct 120 ms 25976 KB Output is correct
69 Correct 119 ms 25976 KB Output is correct
70 Correct 114 ms 25976 KB Output is correct
71 Correct 115 ms 25976 KB Output is correct
72 Correct 116 ms 25928 KB Output is correct
73 Correct 118 ms 25924 KB Output is correct
74 Correct 122 ms 25976 KB Output is correct
75 Correct 118 ms 25924 KB Output is correct
76 Correct 116 ms 25848 KB Output is correct
77 Correct 126 ms 26104 KB Output is correct
78 Correct 123 ms 25848 KB Output is correct
79 Correct 122 ms 25976 KB Output is correct
80 Correct 118 ms 25952 KB Output is correct
81 Correct 120 ms 25976 KB Output is correct
82 Correct 121 ms 25976 KB Output is correct
83 Correct 122 ms 25848 KB Output is correct
84 Correct 122 ms 25976 KB Output is correct
85 Correct 121 ms 25848 KB Output is correct
86 Correct 122 ms 25848 KB Output is correct
87 Correct 122 ms 25848 KB Output is correct
88 Correct 123 ms 25976 KB Output is correct
89 Correct 122 ms 25848 KB Output is correct
90 Correct 122 ms 25848 KB Output is correct
91 Correct 125 ms 25848 KB Output is correct
92 Correct 126 ms 25848 KB Output is correct
93 Correct 127 ms 25884 KB Output is correct
94 Correct 128 ms 25848 KB Output is correct
95 Correct 131 ms 25956 KB Output is correct
96 Correct 128 ms 25848 KB Output is correct
97 Correct 127 ms 25848 KB Output is correct
98 Correct 129 ms 25848 KB Output is correct
99 Correct 127 ms 25952 KB Output is correct
100 Correct 127 ms 25848 KB Output is correct
101 Correct 128 ms 25848 KB Output is correct
102 Correct 131 ms 25924 KB Output is correct