Submission #472652

# Submission time Handle Problem Language Result Execution time Memory
472652 2021-09-14T02:10:25 Z ITO Lamps (JOI19_lamps) C++11
100 / 100
322 ms 67068 KB
#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
typedef long long ll;
string s1, s2, sa[16] = {"", "0", "1", "f", "01", "0f", "10", "1f", "f0", "f1", "01f", "0f1", "10f", "1f0", "f01", "f10"};
int a[1000001][16];
struct lol {
    string s;
    int t, c[16];
} la[16];
lol nom(string ss) {
    lol tm;
    tm.s = ss;
    tm.t = 3;
    for (char cc : ss) {
        if (cc == '0') {
            tm.t = 0;
        } else if (cc == '1') {
            tm.t = 1;
        } else {
            if (tm.t < 2) {
                tm.t = 1 - tm.t;
            } else {
                tm.t = 2;
            }
        }
    }
    for (int i = 0; i < 16; i++) {
        int k = 0;
        tm.c[i] = ss.length();
        for (int jj = 0; jj < ss.length(); jj++) {
            for (int kk = k; kk < sa[i].length(); kk++) {
                if (ss[jj] == sa[i][kk]) {
                    tm.c[i]--;
                    k = kk + 1;
                    break;
                }
            }
        }
    }
    return tm;
}
int main() {
    int n;
    cin >> n >> s1 >> s2;
    for (int i = 0; i < 16; i++) {
        la[i] = nom(sa[i]);
        a[0][i] = 10000000;
    }
    a[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 16; j++) {
            a[i + 1][j] = 10000000;
            if ((la[j].t == 3 && s1[i] == s2[i]) || (la[j].t == 2 && s1[i] != s2[i]) || (la[j].t == s2[i] - '0')) {
                for (int k = 0; k < 16; k++) {
                    a[i + 1][j] = min(a[i + 1][j], a[i][k] + la[j].c[k]);
                }
            }
        }
    }
    int co = 10000000;
    for (int i = 0; i < 16; i++) {
        co = min(co, a[n][i]);
    }
    cout << co << '\n';
    return 0;
}

Compilation message

lamp.cpp: In function 'lol nom(std::string)':
lamp.cpp:31:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (int jj = 0; jj < ss.length(); jj++) {
      |                          ~~~^~~~~~~~~~~~~
lamp.cpp:32:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             for (int kk = k; kk < sa[i].length(); kk++) {
      |                              ~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 432 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 292 ms 66904 KB Output is correct
8 Correct 294 ms 66864 KB Output is correct
9 Correct 313 ms 66872 KB Output is correct
10 Correct 288 ms 66896 KB Output is correct
11 Correct 289 ms 66864 KB Output is correct
12 Correct 279 ms 66884 KB Output is correct
13 Correct 299 ms 66968 KB Output is correct
14 Correct 291 ms 66852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 432 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 1 ms 204 KB Output is correct
62 Correct 1 ms 204 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 292 ms 66904 KB Output is correct
66 Correct 294 ms 66864 KB Output is correct
67 Correct 313 ms 66872 KB Output is correct
68 Correct 288 ms 66896 KB Output is correct
69 Correct 289 ms 66864 KB Output is correct
70 Correct 279 ms 66884 KB Output is correct
71 Correct 299 ms 66968 KB Output is correct
72 Correct 291 ms 66852 KB Output is correct
73 Correct 303 ms 66892 KB Output is correct
74 Correct 279 ms 66920 KB Output is correct
75 Correct 283 ms 66868 KB Output is correct
76 Correct 285 ms 66920 KB Output is correct
77 Correct 283 ms 66940 KB Output is correct
78 Correct 322 ms 66876 KB Output is correct
79 Correct 279 ms 66864 KB Output is correct
80 Correct 279 ms 66884 KB Output is correct
81 Correct 289 ms 66928 KB Output is correct
82 Correct 295 ms 66940 KB Output is correct
83 Correct 287 ms 66856 KB Output is correct
84 Correct 292 ms 66972 KB Output is correct
85 Correct 288 ms 66832 KB Output is correct
86 Correct 294 ms 67068 KB Output is correct
87 Correct 287 ms 66920 KB Output is correct
88 Correct 293 ms 66944 KB Output is correct
89 Correct 293 ms 67012 KB Output is correct
90 Correct 292 ms 66912 KB Output is correct
91 Correct 290 ms 66896 KB Output is correct
92 Correct 296 ms 66916 KB Output is correct
93 Correct 295 ms 66940 KB Output is correct
94 Correct 295 ms 66856 KB Output is correct
95 Correct 295 ms 66896 KB Output is correct
96 Correct 295 ms 66852 KB Output is correct
97 Correct 321 ms 66944 KB Output is correct
98 Correct 296 ms 66956 KB Output is correct
99 Correct 297 ms 66940 KB Output is correct
100 Correct 290 ms 66864 KB Output is correct
101 Correct 293 ms 66904 KB Output is correct
102 Correct 299 ms 67004 KB Output is correct