Submission #680145

# Submission time Handle Problem Language Result Execution time Memory
680145 2023-01-10T02:31:39 Z Duy_e Snake Escaping (JOI18_snake_escaping) C++14
22 / 100
1671 ms 23020 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair <ll, ll>
#define st first
#define nd second
#define rep(i, n, m) for (ll i = (n); i <= (m); i ++)
#define rrep(i, n, m) for (ll i = (n); i >= (m); i --)
using namespace std;
const long long INF = 1e18;
const long long N = 1e6 + 5;
const long long mask_Max = 2e6;
int n, q, L;
ll a[N], f[mask_Max];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);

    cin >> L >> q;
    n = 1ll << L;
    rep(i, 0, n - 1) {
        char ch;
        cin >> ch;
        a[i] = ch - '0';
    }

    rep(i, 0, n - 1) {
        rep(j, 0, n - 1) {
            ll cur = 0;
            rep(k, 0, L - 1) {
                ll val = 2;
                if (j >> k & 1) {
                    if (i >> k & 1) val = 1; else val = 0;
                }
                cur = cur * 3 + val;
            }
            f[cur] += a[i];
        }
    }

    string t;
    while (q --) {
        cin >> t;
        reverse(t.begin(), t.end());
        ll val = 0;
        rep(i, 0, L - 1) {
            if (t[i] == '1') val = val * 3 + 1;
            if (t[i] == '0') val = val * 3;
            if (t[i] == '?') val = val * 3 + 2;
        }

        cout << f[val] << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 820 KB Output is correct
2 Correct 15 ms 724 KB Output is correct
3 Correct 17 ms 820 KB Output is correct
4 Correct 16 ms 824 KB Output is correct
5 Correct 15 ms 824 KB Output is correct
6 Correct 12 ms 724 KB Output is correct
7 Correct 12 ms 824 KB Output is correct
8 Correct 12 ms 720 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 12 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 820 KB Output is correct
2 Correct 15 ms 724 KB Output is correct
3 Correct 17 ms 820 KB Output is correct
4 Correct 16 ms 824 KB Output is correct
5 Correct 15 ms 824 KB Output is correct
6 Correct 12 ms 724 KB Output is correct
7 Correct 12 ms 824 KB Output is correct
8 Correct 12 ms 720 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 12 ms 724 KB Output is correct
11 Correct 215 ms 9620 KB Output is correct
12 Correct 264 ms 9248 KB Output is correct
13 Correct 213 ms 8592 KB Output is correct
14 Correct 214 ms 8632 KB Output is correct
15 Correct 212 ms 9548 KB Output is correct
16 Correct 222 ms 8756 KB Output is correct
17 Correct 226 ms 8744 KB Output is correct
18 Correct 166 ms 10620 KB Output is correct
19 Correct 196 ms 7636 KB Output is correct
20 Correct 198 ms 9356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 820 KB Output is correct
2 Correct 15 ms 724 KB Output is correct
3 Correct 17 ms 820 KB Output is correct
4 Correct 16 ms 824 KB Output is correct
5 Correct 15 ms 824 KB Output is correct
6 Correct 12 ms 724 KB Output is correct
7 Correct 12 ms 824 KB Output is correct
8 Correct 12 ms 720 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 12 ms 724 KB Output is correct
11 Correct 215 ms 9620 KB Output is correct
12 Correct 264 ms 9248 KB Output is correct
13 Correct 213 ms 8592 KB Output is correct
14 Correct 214 ms 8632 KB Output is correct
15 Correct 212 ms 9548 KB Output is correct
16 Correct 222 ms 8756 KB Output is correct
17 Correct 226 ms 8744 KB Output is correct
18 Correct 166 ms 10620 KB Output is correct
19 Correct 196 ms 7636 KB Output is correct
20 Correct 198 ms 9356 KB Output is correct
21 Correct 1388 ms 21084 KB Output is correct
22 Correct 1525 ms 21172 KB Output is correct
23 Correct 1671 ms 20280 KB Output is correct
24 Correct 1555 ms 20084 KB Output is correct
25 Correct 1381 ms 22188 KB Output is correct
26 Correct 1471 ms 20616 KB Output is correct
27 Correct 1479 ms 20564 KB Output is correct
28 Correct 1349 ms 23020 KB Output is correct
29 Correct 1358 ms 19084 KB Output is correct
30 Correct 1383 ms 21172 KB Output is correct
31 Correct 1471 ms 21172 KB Output is correct
32 Correct 1447 ms 21040 KB Output is correct
33 Correct 1403 ms 19888 KB Output is correct
34 Correct 1448 ms 20020 KB Output is correct
35 Correct 1522 ms 20592 KB Output is correct
36 Correct 1384 ms 19116 KB Output is correct
37 Correct 1409 ms 21040 KB Output is correct
38 Correct 1383 ms 19120 KB Output is correct
39 Correct 1642 ms 20272 KB Output is correct
40 Correct 1436 ms 20256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 820 KB Output is correct
2 Correct 15 ms 724 KB Output is correct
3 Correct 17 ms 820 KB Output is correct
4 Correct 16 ms 824 KB Output is correct
5 Correct 15 ms 824 KB Output is correct
6 Correct 12 ms 724 KB Output is correct
7 Correct 12 ms 824 KB Output is correct
8 Correct 12 ms 720 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 12 ms 724 KB Output is correct
11 Incorrect 16 ms 9232 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 820 KB Output is correct
2 Correct 15 ms 724 KB Output is correct
3 Correct 17 ms 820 KB Output is correct
4 Correct 16 ms 824 KB Output is correct
5 Correct 15 ms 824 KB Output is correct
6 Correct 12 ms 724 KB Output is correct
7 Correct 12 ms 824 KB Output is correct
8 Correct 12 ms 720 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 12 ms 724 KB Output is correct
11 Correct 215 ms 9620 KB Output is correct
12 Correct 264 ms 9248 KB Output is correct
13 Correct 213 ms 8592 KB Output is correct
14 Correct 214 ms 8632 KB Output is correct
15 Correct 212 ms 9548 KB Output is correct
16 Correct 222 ms 8756 KB Output is correct
17 Correct 226 ms 8744 KB Output is correct
18 Correct 166 ms 10620 KB Output is correct
19 Correct 196 ms 7636 KB Output is correct
20 Correct 198 ms 9356 KB Output is correct
21 Correct 1388 ms 21084 KB Output is correct
22 Correct 1525 ms 21172 KB Output is correct
23 Correct 1671 ms 20280 KB Output is correct
24 Correct 1555 ms 20084 KB Output is correct
25 Correct 1381 ms 22188 KB Output is correct
26 Correct 1471 ms 20616 KB Output is correct
27 Correct 1479 ms 20564 KB Output is correct
28 Correct 1349 ms 23020 KB Output is correct
29 Correct 1358 ms 19084 KB Output is correct
30 Correct 1383 ms 21172 KB Output is correct
31 Correct 1471 ms 21172 KB Output is correct
32 Correct 1447 ms 21040 KB Output is correct
33 Correct 1403 ms 19888 KB Output is correct
34 Correct 1448 ms 20020 KB Output is correct
35 Correct 1522 ms 20592 KB Output is correct
36 Correct 1384 ms 19116 KB Output is correct
37 Correct 1409 ms 21040 KB Output is correct
38 Correct 1383 ms 19120 KB Output is correct
39 Correct 1642 ms 20272 KB Output is correct
40 Correct 1436 ms 20256 KB Output is correct
41 Incorrect 16 ms 9232 KB Output isn't correct
42 Halted 0 ms 0 KB -