# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522223 | 2022-02-04T08:13:54 Z | Monarchuwu | Snake Escaping (JOI18_snake_escaping) | C++17 | 228 ms | 16488 KB |
#include<iostream> #include<algorithm> #include<string> #define all(x) x.begin(), x.end() using namespace std; typedef long long ll; const int N = 2e6 + 10; int l, q; string s; int pw3[13], a[N]; void prep() { pw3[0] = 1; for (int i = 1; i < 13; ++i) pw3[i] = pw3[i - 1] * 3; for (int i = 0, msk, x; i < s.size(); ++i) { msk = 0, x = i; for (int j = 0; j < l; ++j) if (x >> j & 1) msk += pw3[j]; a[msk] = s[i] ^ 48; } for (int j = 0; j < l; ++j) for (int msk = 0; msk < pw3[l]; ++msk) if (msk / pw3[j] % 3 == 2) a[msk] += a[msk - pw3[j]] + a[msk - pw3[j] * 2]; } int main() { cin.tie(NULL)->sync_with_stdio(false); cin >> l >> q >> s; prep(); while (q--) { string t; cin >> t; int msk(0); for (char c : t) { msk *= 3; if (c == '1') ++msk; else if (c == '?') msk += 2; } cout << a[msk] << '\n'; } } /** /\_/\ * (= ._.) * / >0 \>1 **/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 460 KB | Output is correct |
2 | Correct | 4 ms | 432 KB | Output is correct |
3 | Correct | 4 ms | 460 KB | Output is correct |
4 | Correct | 4 ms | 460 KB | Output is correct |
5 | Correct | 4 ms | 460 KB | Output is correct |
6 | Correct | 4 ms | 452 KB | Output is correct |
7 | Correct | 4 ms | 456 KB | Output is correct |
8 | Correct | 5 ms | 460 KB | Output is correct |
9 | Correct | 5 ms | 684 KB | Output is correct |
10 | Correct | 4 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 460 KB | Output is correct |
2 | Correct | 4 ms | 432 KB | Output is correct |
3 | Correct | 4 ms | 460 KB | Output is correct |
4 | Correct | 4 ms | 460 KB | Output is correct |
5 | Correct | 4 ms | 460 KB | Output is correct |
6 | Correct | 4 ms | 452 KB | Output is correct |
7 | Correct | 4 ms | 456 KB | Output is correct |
8 | Correct | 5 ms | 460 KB | Output is correct |
9 | Correct | 5 ms | 684 KB | Output is correct |
10 | Correct | 4 ms | 460 KB | Output is correct |
11 | Correct | 193 ms | 15256 KB | Output is correct |
12 | Correct | 158 ms | 14848 KB | Output is correct |
13 | Correct | 179 ms | 14160 KB | Output is correct |
14 | Correct | 212 ms | 14296 KB | Output is correct |
15 | Correct | 172 ms | 15296 KB | Output is correct |
16 | Correct | 190 ms | 14444 KB | Output is correct |
17 | Correct | 189 ms | 14360 KB | Output is correct |
18 | Correct | 159 ms | 16196 KB | Output is correct |
19 | Correct | 193 ms | 13244 KB | Output is correct |
20 | Correct | 219 ms | 14852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 460 KB | Output is correct |
2 | Correct | 4 ms | 432 KB | Output is correct |
3 | Correct | 4 ms | 460 KB | Output is correct |
4 | Correct | 4 ms | 460 KB | Output is correct |
5 | Correct | 4 ms | 460 KB | Output is correct |
6 | Correct | 4 ms | 452 KB | Output is correct |
7 | Correct | 4 ms | 456 KB | Output is correct |
8 | Correct | 5 ms | 460 KB | Output is correct |
9 | Correct | 5 ms | 684 KB | Output is correct |
10 | Correct | 4 ms | 460 KB | Output is correct |
11 | Correct | 193 ms | 15256 KB | Output is correct |
12 | Correct | 158 ms | 14848 KB | Output is correct |
13 | Correct | 179 ms | 14160 KB | Output is correct |
14 | Correct | 212 ms | 14296 KB | Output is correct |
15 | Correct | 172 ms | 15296 KB | Output is correct |
16 | Correct | 190 ms | 14444 KB | Output is correct |
17 | Correct | 189 ms | 14360 KB | Output is correct |
18 | Correct | 159 ms | 16196 KB | Output is correct |
19 | Correct | 193 ms | 13244 KB | Output is correct |
20 | Correct | 219 ms | 14852 KB | Output is correct |
21 | Incorrect | 228 ms | 16488 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 460 KB | Output is correct |
2 | Correct | 4 ms | 432 KB | Output is correct |
3 | Correct | 4 ms | 460 KB | Output is correct |
4 | Correct | 4 ms | 460 KB | Output is correct |
5 | Correct | 4 ms | 460 KB | Output is correct |
6 | Correct | 4 ms | 452 KB | Output is correct |
7 | Correct | 4 ms | 456 KB | Output is correct |
8 | Correct | 5 ms | 460 KB | Output is correct |
9 | Correct | 5 ms | 684 KB | Output is correct |
10 | Correct | 4 ms | 460 KB | Output is correct |
11 | Runtime error | 9 ms | 5100 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 460 KB | Output is correct |
2 | Correct | 4 ms | 432 KB | Output is correct |
3 | Correct | 4 ms | 460 KB | Output is correct |
4 | Correct | 4 ms | 460 KB | Output is correct |
5 | Correct | 4 ms | 460 KB | Output is correct |
6 | Correct | 4 ms | 452 KB | Output is correct |
7 | Correct | 4 ms | 456 KB | Output is correct |
8 | Correct | 5 ms | 460 KB | Output is correct |
9 | Correct | 5 ms | 684 KB | Output is correct |
10 | Correct | 4 ms | 460 KB | Output is correct |
11 | Correct | 193 ms | 15256 KB | Output is correct |
12 | Correct | 158 ms | 14848 KB | Output is correct |
13 | Correct | 179 ms | 14160 KB | Output is correct |
14 | Correct | 212 ms | 14296 KB | Output is correct |
15 | Correct | 172 ms | 15296 KB | Output is correct |
16 | Correct | 190 ms | 14444 KB | Output is correct |
17 | Correct | 189 ms | 14360 KB | Output is correct |
18 | Correct | 159 ms | 16196 KB | Output is correct |
19 | Correct | 193 ms | 13244 KB | Output is correct |
20 | Correct | 219 ms | 14852 KB | Output is correct |
21 | Incorrect | 228 ms | 16488 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |