Submission #709277

#TimeUsernameProblemLanguageResultExecution timeMemory
709277vjudge1Homework (CEOI22_homework)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define x first #define y second #define sz(v) (int)v.size() #define pb push_back #define nl "\n" using namespace std; const int N = (int)1e6 + 7; const int inf = (int)1e9 + 7; int n, pos[N], p[N], e[N]; bool dp[500][16][1 << 16]; vector<int> v[1 << 16]; string s; void calc(int v, int l, int r) { if(l == r) { for(int i = 0; i < n; ++i) { dp[v][i][1 << i] = 1; } return; } bool tp = (s[l + 1] == 'a'); int mid = e[l]; calc(v * 2, l + 4, mid - 1); calc(v * 2 + 1, mid + 1, r - 1); for(int mask = 0; mask < (1 << n); ++mask) { int msk = (((1 << n) - 1) ^ mask); for(int s = msk; s; s = (s - 1) & msk) { for(int x : v[mask]) { for(int y : v[s]) { dp[v][(tp ? max(x, y) : min(x, y))][mask | s] |= (dp[v * 2][x][mask] & dp[v * 2 + 1][y][s]); } } } } } int main() { ios_base::sync_with_stdio(NULL); cin.tie(0); cin >> s; for(int i = 0; i < sz(s); ++i) { if(s[i] == '?') { pos[i] = ++n; } } for(int mask = 0; mask < (1 << n); ++mask) { for(int i = 0; i < n; ++i) { if(mask >> i & 1) v[mask].pb(i); } } stack<int> st; for(int i = 0; i < sz(s); ++i) { if(s[i] == 'm') st.push(i); if(s[i] == ',') { assert(!st.empty()); e[st.top()] = i; st.pop(); } } calc(1, 0, sz(s) - 1); int ans = 0; for(int i = 0; i < n; ++i) ans += dp[1][i][(1 << n) - 1]; cout << ans; return 0; }

Compilation message (stderr)

Main.cpp: In function 'void calc(int, int, int)':
Main.cpp:33:17: error: invalid types 'int[int]' for array subscript
   33 |    for(int x : v[mask]) {
      |                 ^
Main.cpp:34:18: error: invalid types 'int[int]' for array subscript
   34 |     for(int y : v[s]) {
      |                  ^