Submission #702357

# Submission time Handle Problem Language Result Execution time Memory
702357 2023-02-23T16:32:22 Z bebra Snake Escaping (JOI18_snake_escaping) C++17
5 / 100
2000 ms 15116 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 total_mask = 0;
        vector<int> marks;
        for (int i = 0; i < k; ++i) {
            if (t[i] == '?') {
                marks.push_back(i);
            } else if (t[i] == '1') {
                total_mask |= 1 << i;
            }
        }
        int unknown_cnt = marks.size();
        int res = 0;
        for (int mask = 0; mask < (1 << unknown_cnt); ++mask) {
            int curr_mask = total_mask;
            for (int i = 0; i < unknown_cnt; ++i) {
                if (mask & (1 << i)) {
                    curr_mask |= 1 << marks[i];
                }
            }
            res += s[curr_mask] - '0';
        }
        cout << res << '\n';
    }
    
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 30 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 30 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 532 ms 15052 KB Output is correct
12 Correct 1182 ms 14768 KB Output is correct
13 Correct 351 ms 13992 KB Output is correct
14 Correct 315 ms 14068 KB Output is correct
15 Correct 883 ms 15116 KB Output is correct
16 Correct 422 ms 14152 KB Output is correct
17 Correct 463 ms 14176 KB Output is correct
18 Execution timed out 2069 ms 1660 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 30 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 532 ms 15052 KB Output is correct
12 Correct 1182 ms 14768 KB Output is correct
13 Correct 351 ms 13992 KB Output is correct
14 Correct 315 ms 14068 KB Output is correct
15 Correct 883 ms 15116 KB Output is correct
16 Correct 422 ms 14152 KB Output is correct
17 Correct 463 ms 14176 KB Output is correct
18 Execution timed out 2069 ms 1660 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 30 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1449 ms 3784 KB Output is correct
12 Execution timed out 2069 ms 3664 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 30 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 532 ms 15052 KB Output is correct
12 Correct 1182 ms 14768 KB Output is correct
13 Correct 351 ms 13992 KB Output is correct
14 Correct 315 ms 14068 KB Output is correct
15 Correct 883 ms 15116 KB Output is correct
16 Correct 422 ms 14152 KB Output is correct
17 Correct 463 ms 14176 KB Output is correct
18 Execution timed out 2069 ms 1660 KB Time limit exceeded
19 Halted 0 ms 0 KB -