Submission #1136760

#TimeUsernameProblemLanguageResultExecution timeMemory
1136760_callmelucianSnake Escaping (JOI18_snake_escaping)C11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pl; typedef pair<int,int> pii; typedef tuple<int,int,int> tt; #define all(a) a.begin(), a.end() #define filter(a) a.erase(unique(all(a)), a.end()) int toxic[1 << 20], sosSub[1 << 20], sosSuper[1 << 20]; int main() { ios::sync_with_stdio(0); cin.tie(0); int k, Q; cin >> k >> Q; for (int i = 0; i < (1 << k); i++) { char c; cin >> c; toxic[i] = sosSub[i] = sosSuper[i] = c - '0'; } for (int i = 0; i < k; i++) { for (int mask = 0; mask < (1 << k); mask++) { if (mask & (1 << i)) sosSub[mask] += sosSub[mask ^ (1 << i)]; else sosSuper[mask] += sosSuper[mask ^ (1 << i)]; } } int full = (1 << k) - 1; while (Q--) { string s; cin >> s; reverse(all(s)); int maskZ = 0, maskO = 0, maskQ = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') maskZ |= (1 << i); if (s[i] == '1') maskO |= (1 << i); if (s[i] == '?') maskQ |= (1 << i); } int ans = 0; if (__builtin_popcount(maskQ) <= 6) { ans = toxic[maskO]; for (int sub = maskQ; sub; sub = (sub - 1) & maskQ) ans += toxic[sub | maskO]; } else if (__builtin_popcount(maskO) <= 6) { ans = sosSub[maskQ] * (__builtin_parity(maskO) ? -1 : 1); for (int sub = maskO; sub; sub = (sub - 1) & maskO) { if (__builtin_parity(sub) ^ __builtin_parity(maskO)) ans -= sosSub[sub | maskQ]; else ans += sosSub[sub | maskQ]; } } else if (__builtin_popcount(maskZ) <= 6) { ans = sosSuper[maskO]; for (int sub = maskZ; sub; sub = (sub - 1) & maskZ) { if (__builtin_parity(sub)) ans -= sosSuper[sub | maskO]; else ans += sosSuper[sub | maskO]; } } cout << ans << "\n"; } return 0; }

Compilation message (stderr)

snake_escaping.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.