Submission #1094358

#TimeUsernameProblemLanguageResultExecution timeMemory
1094358SunbaeSeptember (APIO24_september)C++17
Compilation error
0 ms0 KiB
#include <cstdio> #include <algorithm> #include <vector> #include <cassert> #include "september.h" using namespace std; const int N = 1e5 + 5, M = 2e5 + 20; vector<int> g[N]; int bit[M], tin[N], tout[N], mn[N], mx[N], ti; void upd(int i, int v){ for(; i<M; i+=i&-i) bit[i] += v;} int qry(int i){ int r = 0; for(; i; i-=i&-i) r += bit[i]; return r;} void dfs(int u){ tin[u] = ti++; for(int v: g[u]) dfs(v); tout[u] = ti-1; } int solve(int n, int m, vector<int> up, vector<vector<int>> S){ for(int i = 0; i<n; ++i) g[i].clear(); for(int i = ti = 1; i<n; ++i) g[up[i]].push_back(i); dfs(0); fill(mn, mn+n, n+1); fill(mx, mx+n, 0); for(int i = 0, cnt; i<m; ++i){ fill(bit, bit+n+1, cnt = 0); for(int u: S[i]){ if(!qry(tin[u])){ ++cnt; upd(tin[u], +cnt); upd(tout[u]+1, -cnt); } } for(int j = 1; j<n; ++j){ int tmp = qry(tin[j]); mn[j] = min(mn[j], tmp); mx[j] = max(mx[j], tmp); } } fill(bit, bit+(n<<1)+20, 0); int MN = (n<<1) + 20, MX = 0; for(int i = 1; i<n; ++i){ int l = (mn[i]<<1), r = (mx[i]<<1); upd(l, +1); upd(r+1, -1); MN = min(MN, l); MX = max(MX, r); } int cnt = 0; for(int i = MN; i<=MX; ++i) if(qry(i) && !qry(i-1)) ++cnt; assert(cnt > = 0 && cnt < n); return cnt; }

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from september.cpp:4:
september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:45:15: error: expected primary-expression before '=' token
   45 |  assert(cnt > = 0 && cnt < n);
      |               ^