Submission #1037890

#TimeUsernameProblemLanguageResultExecution timeMemory
1037890vjudge1Snake Escaping (JOI18_snake_escaping)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define pb push_back const int mxn = 2e6 + 3; const int lg = 21; int n, q; int A[mxn]; int dp[mxn], pd[mxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q; string s; cin >> s; for(int i = 0; i < (1 << n); i ++) { int x = (s[i] - '0'); A[i] = x; dp[i] = pd[i] = x; } for(int i = 0; i < n; i ++) for(int mask = 0; mask < (1 << n); mask ++) if(mask >> i & 1) dp[mask] += dp[mask ^ (1 << i)]; else pd[mask] += pd[mask ^ (1 << i)]; while(q --) { vector<int> c0, c1, c2; int x = 0; string st; cin >> st; reverse(all(st)); for(int i = 0; i < n; i ++) { char c = st[i]; if(c == '1') x += (1 << i); if(c == '0') c0.pb(i); if(c == '1') c1.pb(i); if(c == '?') c2.pb(i); } if(c2.size() <= 6) { int f = c2.size(), ans = 0; for(int mask = 0; mask < (1 << f); mask ++) { int y = x; for(int i = 0; i < f; i ++) if(mask >> i & 1) y ^= (1 << c2[i]); ans += A[y]; } cout << ans << '\n'; continue; } if(c1.size() <= 6) { int f = c1.size(); for(int i : c2) x ^= (1 << i); int ans = 0; for(int mask = 0; mask < (1 << f); mask ++) { int y = x; for(int i = 0; i < f; i ++) if(mask >> i & 1) y ^= (1 << c1[i]); if(__builtin_popcount(mask) & 1) ans -= dp[y]; else ans += dp[y]; } cout << ans << '\n'; continue; } if(c0.size() <= 6) { int f = c0.size(); int ans = 0; for(int mask = 0; mask < (1 << f); mask ++) { int y = x; for(int i = 0; i < f; i ++) if(mask >> i & 1) y ^= (1 << c0[i]); if(__builtin_popcount(mask) & 1) ans -= pd[y]; else ans += pd[y]; } cout << ans << '\n'; continue; } } return 0; }

Compilation message (stderr)

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:42:17: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   42 |         reverse(all(st));
      |                 ^~~
      |                 std::filesystem::perms::all
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from snake_escaping.cpp:1:
/usr/include/c++/10/bits/fs_fwd.h:148:7: note: 'std::filesystem::perms::all' declared here
  148 |       all  =  0777,
      |       ^~~