Submission #502460

# Submission time Handle Problem Language Result Execution time Memory
502460 2022-01-06T04:12:13 Z zorianka Snake Escaping (JOI18_snake_escaping) C++17
12 / 100
2000 ms 65540 KB
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
    int l, q;
    cin >> l >> q;
    string s;
    cin >> s;
    unordered_map<string, int> d;
    d.reserve(1 << l);
    for (int i = 0; i < (1 << l); i++) {
        for (int mask = 0; mask < (1 << l); mask++) {
            string t = "";
            for (int j = l - 1; j > -1; j--) {
                if (mask & (1 << j))
                    t += '?';
                else
                    t += '0' + ((i & (1 << j)) != 0);
            }
            d[t] += s[i] - '0';
        }
    }
    while (q--) {
        string t;
        cin >> t;
        cout << d[t] << '\n';
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 152 ms 4540 KB Output is correct
2 Correct 147 ms 4520 KB Output is correct
3 Correct 149 ms 4512 KB Output is correct
4 Correct 148 ms 4576 KB Output is correct
5 Correct 150 ms 4532 KB Output is correct
6 Correct 158 ms 4536 KB Output is correct
7 Correct 145 ms 4612 KB Output is correct
8 Correct 147 ms 4572 KB Output is correct
9 Correct 155 ms 4536 KB Output is correct
10 Correct 148 ms 4536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 4540 KB Output is correct
2 Correct 147 ms 4520 KB Output is correct
3 Correct 149 ms 4512 KB Output is correct
4 Correct 148 ms 4576 KB Output is correct
5 Correct 150 ms 4532 KB Output is correct
6 Correct 158 ms 4536 KB Output is correct
7 Correct 145 ms 4612 KB Output is correct
8 Correct 147 ms 4572 KB Output is correct
9 Correct 155 ms 4536 KB Output is correct
10 Correct 148 ms 4536 KB Output is correct
11 Correct 1690 ms 8892 KB Output is correct
12 Correct 1689 ms 8632 KB Output is correct
13 Correct 1739 ms 7780 KB Output is correct
14 Correct 1743 ms 7976 KB Output is correct
15 Correct 1755 ms 8952 KB Output is correct
16 Correct 1727 ms 8284 KB Output is correct
17 Correct 1752 ms 8052 KB Output is correct
18 Correct 1671 ms 9820 KB Output is correct
19 Correct 1648 ms 6884 KB Output is correct
20 Correct 1736 ms 8548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 4540 KB Output is correct
2 Correct 147 ms 4520 KB Output is correct
3 Correct 149 ms 4512 KB Output is correct
4 Correct 148 ms 4576 KB Output is correct
5 Correct 150 ms 4532 KB Output is correct
6 Correct 158 ms 4536 KB Output is correct
7 Correct 145 ms 4612 KB Output is correct
8 Correct 147 ms 4572 KB Output is correct
9 Correct 155 ms 4536 KB Output is correct
10 Correct 148 ms 4536 KB Output is correct
11 Correct 1690 ms 8892 KB Output is correct
12 Correct 1689 ms 8632 KB Output is correct
13 Correct 1739 ms 7780 KB Output is correct
14 Correct 1743 ms 7976 KB Output is correct
15 Correct 1755 ms 8952 KB Output is correct
16 Correct 1727 ms 8284 KB Output is correct
17 Correct 1752 ms 8052 KB Output is correct
18 Correct 1671 ms 9820 KB Output is correct
19 Correct 1648 ms 6884 KB Output is correct
20 Correct 1736 ms 8548 KB Output is correct
21 Execution timed out 2077 ms 35696 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 152 ms 4540 KB Output is correct
2 Correct 147 ms 4520 KB Output is correct
3 Correct 149 ms 4512 KB Output is correct
4 Correct 148 ms 4576 KB Output is correct
5 Correct 150 ms 4532 KB Output is correct
6 Correct 158 ms 4536 KB Output is correct
7 Correct 145 ms 4612 KB Output is correct
8 Correct 147 ms 4572 KB Output is correct
9 Correct 155 ms 4536 KB Output is correct
10 Correct 148 ms 4536 KB Output is correct
11 Runtime error 245 ms 65540 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 152 ms 4540 KB Output is correct
2 Correct 147 ms 4520 KB Output is correct
3 Correct 149 ms 4512 KB Output is correct
4 Correct 148 ms 4576 KB Output is correct
5 Correct 150 ms 4532 KB Output is correct
6 Correct 158 ms 4536 KB Output is correct
7 Correct 145 ms 4612 KB Output is correct
8 Correct 147 ms 4572 KB Output is correct
9 Correct 155 ms 4536 KB Output is correct
10 Correct 148 ms 4536 KB Output is correct
11 Correct 1690 ms 8892 KB Output is correct
12 Correct 1689 ms 8632 KB Output is correct
13 Correct 1739 ms 7780 KB Output is correct
14 Correct 1743 ms 7976 KB Output is correct
15 Correct 1755 ms 8952 KB Output is correct
16 Correct 1727 ms 8284 KB Output is correct
17 Correct 1752 ms 8052 KB Output is correct
18 Correct 1671 ms 9820 KB Output is correct
19 Correct 1648 ms 6884 KB Output is correct
20 Correct 1736 ms 8548 KB Output is correct
21 Execution timed out 2077 ms 35696 KB Time limit exceeded
22 Halted 0 ms 0 KB -