Submission #985171

#TimeUsernameProblemLanguageResultExecution timeMemory
985171TsaganaSequence (APIO23_sequence)C++17
Compilation error
0 ms0 KiB
#include "sequence.h" //OP #include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define vi vector<int> #define pi pair<int, int > #define pq priority_queue #define lb lower_bound #define ub upper_bound #define pb push_back #define eb emplace_back #define mset multiset #define F first #define S second #define meta int M = (L + R) /2, x = 2 * id + 1, y = x + 1 using namespace std; vector<int> ct[500005]; int N; struct segTree { pi seg[2000005]; int lazy[2000005]; void laze(int id, int l, int r) { if (!lazy[id]) { seg[id] = {seg[id].F + lazy[id], seg[id].S + lazy[id]}; if (l != r) { lazy[i*2+1] += lazy[id]; lazy[i*2+2] += lazy[id]; } lazy[id] = 0; } } void build(int id, int L, int R, int val) { lazy[i] = 0; if (l == r) {seg[i].F = seg[i].S = val * (l); return;} meta; build(x, L, M, val); build(y, M + 1, R, val); seg[id].F = min(seg[x].F, seg[y].F); seg[id].S = max(seg[x].S, seg[y].S); } void build(int val) {build(0, 0, N, val);} void update(int id, int L, int R, int l, int r, int val) { if (L <= l && r >= R) lazy[id] += val; laze(id, L, R); meta; if (l > R || r < L || (l <= L && r >= R)) return; update(x, L, M, l, r, val); update(y, M + 1, R, l, r, val); seg[id].F = min(seg[x].F, seg[y].F); seg[id].S = max(seg[x].S, seg[y].S); } void update(int l, int r, int val) {update(0, 0, N, l + 1, r + 1, val);} pi query(int id, int L, int R, int l, int r) { laze(id, L, R); meta; if (l > R || r < L) return {(int)1e9, (int)-1e9}; if (l <= L && r >= R) return seg[i]; pi q1 = query(x, l, M, l, r); pi q2 = query(y, M + 1, R, l, r); return {min(q1.F, q2.F), max(q1.S, q2.S)}; } pi query(int l, int r) {return query(0, 0, N, l + 1, r + 1);} } les, mor; int sequence(int n, vector<int> A) { N = n; for (int i = 0; i < N; i++) ct[A[i]].pb(i); int ans = 1; les.build(-1); mor.build(1); for (int i = 1; i <= N; i++) { for (int j: ct[i]) les.update(j, N-1, 2); for (int j = 0; j + ans < ct[i].Size(); j++) { int st = ct[i][j]; int en = ct[i][j+ans]; int qles = les.query(en, N-1).S - les.query(-1, st-1).F; int qmor = mor.query(en, N-1).S - mor.query(-1, st-1).F; if (qles >= 0 && qmor >= 0) {ans++; j--;} } for (int j: ct[i]) mor.update(j, N-1, -2); } return ans; } //ED

Compilation message (stderr)

sequence.cpp: In member function 'void segTree::laze(int, int, int)':
sequence.cpp:33:14: error: 'i' was not declared in this scope
   33 |         lazy[i*2+1] += lazy[id];
      |              ^
sequence.cpp: In member function 'void segTree::build(int, int, int, int)':
sequence.cpp:41:10: error: 'i' was not declared in this scope
   41 |     lazy[i] = 0;
      |          ^
sequence.cpp:42:9: error: 'l' was not declared in this scope
   42 |     if (l == r) {seg[i].F = seg[i].S = val * (l); return;}
      |         ^
sequence.cpp:42:14: error: 'r' was not declared in this scope
   42 |     if (l == r) {seg[i].F = seg[i].S = val * (l); return;}
      |              ^
sequence.cpp: In member function 'std::pair<int, int> segTree::query(int, int, int, int, int)':
sequence.cpp:63:38: error: 'i' was not declared in this scope
   63 |     if (l <= L && r >= R) return seg[i];
      |                                      ^
sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:78:37: error: 'class std::vector<int>' has no member named 'Size'; did you mean 'size'?
   78 |     for (int j = 0; j + ans < ct[i].Size(); j++) {
      |                                     ^~~~
      |                                     size