답안 #729399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729399 2023-04-24T02:42:17 Z Pring Snake Escaping (JOI18_snake_escaping) C++14
12 / 100
2000 ms 18848 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int, int> pii;
#define endl '\n'

const int MXN = 1030, MXL = 10;
int l, q, n;
string s, t;
map<string, int> M;

bool MATCH(int x) {
    for (int i = 0; i < l; i++) {
        if (t[i] == '?') {
            x >>= 1;
            continue;
        }
        if ((t[i] & 1) ^ (x & 1)) return false;
        x >>= 1;
    }
    return true;
}

int SOLVE() {
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (MATCH(i)) {
            ans += s[i] - '0';
        }
    }
    return ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> l >> q >> s;
    n = (1 << l);
    while (q--) {
        cin >> t;
        reverse(t.begin(), t.end());
        auto it = M.find(t);
        if (it == M.end()) {
            int x = SOLVE();
            cout << x << endl;
            M[t] = x;
        } else {
            cout << it -> second << endl;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 408 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 9 ms 340 KB Output is correct
6 Correct 8 ms 328 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 408 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 9 ms 340 KB Output is correct
6 Correct 8 ms 328 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 269 ms 15040 KB Output is correct
12 Correct 331 ms 14788 KB Output is correct
13 Correct 491 ms 14552 KB Output is correct
14 Correct 374 ms 14400 KB Output is correct
15 Correct 367 ms 15344 KB Output is correct
16 Correct 465 ms 15400 KB Output is correct
17 Correct 843 ms 18752 KB Output is correct
18 Correct 168 ms 16004 KB Output is correct
19 Correct 260 ms 13068 KB Output is correct
20 Correct 346 ms 14812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 408 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 9 ms 340 KB Output is correct
6 Correct 8 ms 328 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 269 ms 15040 KB Output is correct
12 Correct 331 ms 14788 KB Output is correct
13 Correct 491 ms 14552 KB Output is correct
14 Correct 374 ms 14400 KB Output is correct
15 Correct 367 ms 15344 KB Output is correct
16 Correct 465 ms 15400 KB Output is correct
17 Correct 843 ms 18752 KB Output is correct
18 Correct 168 ms 16004 KB Output is correct
19 Correct 260 ms 13068 KB Output is correct
20 Correct 346 ms 14812 KB Output is correct
21 Correct 441 ms 18168 KB Output is correct
22 Correct 748 ms 18848 KB Output is correct
23 Execution timed out 2063 ms 6536 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 408 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 9 ms 340 KB Output is correct
6 Correct 8 ms 328 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Execution timed out 2067 ms 3696 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 408 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 9 ms 340 KB Output is correct
6 Correct 8 ms 328 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 269 ms 15040 KB Output is correct
12 Correct 331 ms 14788 KB Output is correct
13 Correct 491 ms 14552 KB Output is correct
14 Correct 374 ms 14400 KB Output is correct
15 Correct 367 ms 15344 KB Output is correct
16 Correct 465 ms 15400 KB Output is correct
17 Correct 843 ms 18752 KB Output is correct
18 Correct 168 ms 16004 KB Output is correct
19 Correct 260 ms 13068 KB Output is correct
20 Correct 346 ms 14812 KB Output is correct
21 Correct 441 ms 18168 KB Output is correct
22 Correct 748 ms 18848 KB Output is correct
23 Execution timed out 2063 ms 6536 KB Time limit exceeded
24 Halted 0 ms 0 KB -