# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
860100 | 2023-10-11T16:10:19 Z | green_gold_dog | Snake Escaping (JOI18_snake_escaping) | C++17 | 2000 ms | 35728 KB |
//#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx") #include <bits/stdc++.h> using namespace std; typedef int ll; typedef double db; typedef long double ldb; typedef complex<double> cd; constexpr ll INF64 = 9'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007; constexpr db PI = acos(-1); constexpr bool IS_FILE = false, IS_TEST_CASES = false; random_device rd; mt19937 rnd32(rd()); mt19937_64 rnd64(rd()); template<typename T> bool assign_max(T& a, T b) { if (b > a) { a = b; return true; } return false; } template<typename T> bool assign_min(T& a, T b) { if (b < a) { a = b; return true; } return false; } template<typename T> T square(T a) { return a * a; } template<> struct std::hash<pair<ll, ll>> { ll operator() (pair<ll, ll> p) const { return ((__int128)p.first * MOD + p.second) % INF64; } }; void solve() { ll l, q; cin >> l >> q; vector<ll> ans(q, 0); vector<ll> arr(1 << l, 0); for (ll i = 0; i < (1 << l); i++) { char c; cin >> c; arr[i] = c - '0'; } vector<vector<ll>> all(1 << l); vector<ll> o1(q), o0(q); for (ll i = 0; i < q; i++) { string s; cin >> s; reverse(s.begin(), s.end()); for (ll j = 0; j < l; j++) { if (s[j] == '1') { o1[i] += (1 << j); o0[i] += (1 << j); } if (s[j] == '0') { o1[i] += (1 << j); } if (s[j] == '?') { o0[i] += (1 << j); } } all[o1[i] & o0[i]].push_back(i); } for (ll i = 0; i < (1 << l); i++) { for (auto j : all[i]) { ans[j] += arr[i]; if ((1 << l) - 1 != (i | o1[j])) { all[(((i | o1[j]) + 1) | o1[j]) & o0[j]].push_back(j); } } all[i].clear(); all[i].shrink_to_fit(); } for (auto i : ans) { cout << i << '\n'; } } int main() { if (IS_FILE) { freopen("", "r", stdin); freopen("", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; if (IS_TEST_CASES) { cin >> t; } for (ll i = 0; i < t; i++) { solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 696 ms | 35728 KB | Output is correct |
12 | Correct | 1165 ms | 32784 KB | Output is correct |
13 | Correct | 325 ms | 29864 KB | Output is correct |
14 | Correct | 381 ms | 30616 KB | Output is correct |
15 | Correct | 1235 ms | 31256 KB | Output is correct |
16 | Correct | 492 ms | 30268 KB | Output is correct |
17 | Correct | 548 ms | 30720 KB | Output is correct |
18 | Execution timed out | 2012 ms | 34920 KB | Time limit exceeded |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 696 ms | 35728 KB | Output is correct |
12 | Correct | 1165 ms | 32784 KB | Output is correct |
13 | Correct | 325 ms | 29864 KB | Output is correct |
14 | Correct | 381 ms | 30616 KB | Output is correct |
15 | Correct | 1235 ms | 31256 KB | Output is correct |
16 | Correct | 492 ms | 30268 KB | Output is correct |
17 | Correct | 548 ms | 30720 KB | Output is correct |
18 | Execution timed out | 2012 ms | 34920 KB | Time limit exceeded |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 733 ms | 33244 KB | Output is correct |
12 | Correct | 1969 ms | 30944 KB | Output is correct |
13 | Correct | 120 ms | 30808 KB | Output is correct |
14 | Correct | 235 ms | 31004 KB | Output is correct |
15 | Execution timed out | 2060 ms | 32484 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 696 ms | 35728 KB | Output is correct |
12 | Correct | 1165 ms | 32784 KB | Output is correct |
13 | Correct | 325 ms | 29864 KB | Output is correct |
14 | Correct | 381 ms | 30616 KB | Output is correct |
15 | Correct | 1235 ms | 31256 KB | Output is correct |
16 | Correct | 492 ms | 30268 KB | Output is correct |
17 | Correct | 548 ms | 30720 KB | Output is correct |
18 | Execution timed out | 2012 ms | 34920 KB | Time limit exceeded |
19 | Halted | 0 ms | 0 KB | - |