Submission #702360

# Submission time Handle Problem Language Result Execution time Memory
702360 2023-02-23T16:41:24 Z bebra Snake Escaping (JOI18_snake_escaping) C++17
12 / 100
2000 ms 19064 KB
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cerr << #x << ": " << x << endl;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int k, q;
    cin >> k >> q;

    string s;
    cin >> s;

    while (q--) {
        string t;
        cin >> t;
        reverse(t.begin(), t.end());

        int first_mask = 0;
        int second_mask = 0;
        for (int i = 0; i < k; ++i) {
            if (t[i] == '?') {
                first_mask |= 1 << i;
            } else if (t[i] == '1') {
                second_mask |= 1 << i;
            }
        }
        int res = s[second_mask] - '0';
        for (int submask = first_mask; submask > 0; submask = (submask - 1) & first_mask) {
            res += s[submask | second_mask] - '0';
        }
        cout << res << '\n';
    }
    
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 324 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 324 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 240 ms 12200 KB Output is correct
12 Correct 272 ms 11852 KB Output is correct
13 Correct 224 ms 11248 KB Output is correct
14 Correct 189 ms 11200 KB Output is correct
15 Correct 266 ms 12176 KB Output is correct
16 Correct 208 ms 11452 KB Output is correct
17 Correct 204 ms 11504 KB Output is correct
18 Correct 1207 ms 16056 KB Output is correct
19 Correct 144 ms 13072 KB Output is correct
20 Correct 255 ms 14768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 324 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 240 ms 12200 KB Output is correct
12 Correct 272 ms 11852 KB Output is correct
13 Correct 224 ms 11248 KB Output is correct
14 Correct 189 ms 11200 KB Output is correct
15 Correct 266 ms 12176 KB Output is correct
16 Correct 208 ms 11452 KB Output is correct
17 Correct 204 ms 11504 KB Output is correct
18 Correct 1207 ms 16056 KB Output is correct
19 Correct 144 ms 13072 KB Output is correct
20 Correct 255 ms 14768 KB Output is correct
21 Correct 348 ms 17996 KB Output is correct
22 Correct 432 ms 18248 KB Output is correct
23 Correct 217 ms 17228 KB Output is correct
24 Correct 208 ms 17020 KB Output is correct
25 Correct 465 ms 19064 KB Output is correct
26 Correct 246 ms 17672 KB Output is correct
27 Correct 246 ms 17428 KB Output is correct
28 Execution timed out 2055 ms 5332 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 324 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 74 ms 3852 KB Output is correct
12 Correct 188 ms 3736 KB Output is correct
13 Correct 19 ms 3736 KB Output is correct
14 Correct 25 ms 3696 KB Output is correct
15 Correct 438 ms 3820 KB Output is correct
16 Correct 33 ms 3696 KB Output is correct
17 Correct 35 ms 3748 KB Output is correct
18 Execution timed out 2075 ms 3696 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 324 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 240 ms 12200 KB Output is correct
12 Correct 272 ms 11852 KB Output is correct
13 Correct 224 ms 11248 KB Output is correct
14 Correct 189 ms 11200 KB Output is correct
15 Correct 266 ms 12176 KB Output is correct
16 Correct 208 ms 11452 KB Output is correct
17 Correct 204 ms 11504 KB Output is correct
18 Correct 1207 ms 16056 KB Output is correct
19 Correct 144 ms 13072 KB Output is correct
20 Correct 255 ms 14768 KB Output is correct
21 Correct 348 ms 17996 KB Output is correct
22 Correct 432 ms 18248 KB Output is correct
23 Correct 217 ms 17228 KB Output is correct
24 Correct 208 ms 17020 KB Output is correct
25 Correct 465 ms 19064 KB Output is correct
26 Correct 246 ms 17672 KB Output is correct
27 Correct 246 ms 17428 KB Output is correct
28 Execution timed out 2055 ms 5332 KB Time limit exceeded
29 Halted 0 ms 0 KB -