제출 #985168

#제출 시각아이디문제언어결과실행 시간메모리
985168Tsagana서열 (APIO23_sequence)C++17
컴파일 에러
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

컴파일 시 표준 에러 (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:66:20: error: 'struct std::pair<int, int>' has no member named 'f'
   66 |     return {min(q1.f, q2.f), max(q1.s, q2.s)};
      |                    ^
sequence.cpp:66:26: error: 'struct std::pair<int, int>' has no member named 'f'
   66 |     return {min(q1.f, q2.f), max(q1.s, q2.s)};
      |                          ^
sequence.cpp:66:37: error: 'struct std::pair<int, int>' has no member named 's'
   66 |     return {min(q1.f, q2.f), max(q1.s, q2.s)};
      |                                     ^
sequence.cpp:66:43: error: 'struct std::pair<int, int>' has no member named 's'
   66 |     return {min(q1.f, q2.f), max(q1.s, q2.s)};
      |                                           ^
sequence.cpp:66:45: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<int, int>'
   66 |     return {min(q1.f, q2.f), max(q1.s, q2.s)};
      |                                             ^
      |                                             |
      |                                             <brace-enclosed initializer list>
sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:78:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for (int j = 0; j + ans < ct[i].size(); j++) {
      |                     ~~~~~~~~^~~~~~~~~~~~~~
sequence.cpp:81:37: error: 'struct std::pair<int, int>' has no member named 's'
   81 |       int qles = les.query(en, N-1).s - les.query(-1, st-1).F;
      |                                     ^
sequence.cpp:82:37: error: 'struct std::pair<int, int>' has no member named 's'
   82 |       int qmor = mor.query(en, N-1).s - mor.query(-1, st-1).F;
      |                                     ^