Submission #1154438

#TimeUsernameProblemLanguageResultExecution timeMemory
1154438WongYiKaiIndex (COCI21_index)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef intg ll; const ll MAXN = 200005; vector<int> t[4*MAXN]; int a[MAXN]; void build(int v, int tl, int tr) { if (tl == tr) { t[v] = {a[tl]}; return; } int tm = (tl + tr) / 2; build(v*2, tl, tm); build(v*2+1, tm+1, tr); merge(t[v*2].begin(), t[v*2].end(), t[v*2+1].begin(), t[v*2+1].end(), back_inserter(t[v])); } int query(int v, int tl, int tr, int l, int r, int x) { if (l > tr || tl > r) return 0; if (l == tl && r == tr) { return t[v].end() - lower_bound(t[v].begin(), t[v].end(), x); } int tm = (tl + tr) / 2; return (query(v*2, tl, tm, l, min(r, tm), x)+ query(v*2+1, tm+1, tr, max(l, tm+1), r, x)); } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,q; cin >> n >> q; for (int i=0;i<n;i++){ ll temp; cin >> temp; a[i] = temp; } build(1, 0, n-1); while (q--){ ll l,r; cin >> l >> r; ll range = r-l+1; ll l2=1,r2=range+5; while (l2<r2){ ll m = l2+(r2-l2)/2; if (r2-l2==1) m=r2; if(query(1, 0,n-1, l-1, r-1, m) >= m) l2=m; else r2=m-1; } cout << l2 << "\n"; } }

Compilation message (stderr)

index.cpp:5:9: error: 'intg' does not name a type; did you mean 'int'?
    5 | typedef intg ll;
      |         ^~~~
      |         int
index.cpp:7:7: error: 'll' does not name a type
    7 | const ll MAXN = 200005;
      |       ^~
index.cpp:9:17: error: 'MAXN' was not declared in this scope
    9 | vector<int> t[4*MAXN];
      |                 ^~~~
index.cpp:10:7: error: 'MAXN' was not declared in this scope
   10 | int a[MAXN];
      |       ^~~~
index.cpp: In function 'void build(int, int, int)':
index.cpp:14:9: error: 't' was not declared in this scope
   14 |         t[v] = {a[tl]};
      |         ^
index.cpp:14:17: error: 'a' was not declared in this scope
   14 |         t[v] = {a[tl]};
      |                 ^
index.cpp:20:11: error: 't' was not declared in this scope; did you mean 'tm'?
   20 |     merge(t[v*2].begin(), t[v*2].end(), t[v*2+1].begin(), t[v*2+1].end(),
      |           ^
      |           tm
index.cpp: In function 'int query(int, int, int, int, int, int)':
index.cpp:29:16: error: 't' was not declared in this scope
   29 |         return t[v].end() - lower_bound(t[v].begin(), t[v].end(), x);
      |                ^
index.cpp: In function 'int main()':
index.cpp:40:9: error: 'll' was not declared in this scope
   40 |         ll n,q;
      |         ^~
index.cpp:41:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   41 |         cin >> n >> q;
      |                ^
      |                yn
index.cpp:41:21: error: 'q' was not declared in this scope
   41 |         cin >> n >> q;
      |                     ^
index.cpp:43:19: error: expected ';' before 'temp'
   43 |                 ll temp;
      |                   ^~~~~
      |                   ;
index.cpp:44:24: error: 'temp' was not declared in this scope; did you mean 'tm'?
   44 |                 cin >> temp;
      |                        ^~~~
      |                        tm
index.cpp:45:17: error: 'a' was not declared in this scope
   45 |                 a[i] = temp;
      |                 ^
index.cpp:52:19: error: expected ';' before 'l'
   52 |                 ll l,r;
      |                   ^~
      |                   ;
index.cpp:53:24: error: 'l' was not declared in this scope
   53 |                 cin >> l >> r;
      |                        ^
index.cpp:53:29: error: 'r' was not declared in this scope
   53 |                 cin >> l >> r;
      |                             ^
index.cpp:54:19: error: expected ';' before 'range'
   54 |                 ll range = r-l+1;
      |                   ^~~~~~
      |                   ;
index.cpp:55:19: error: expected ';' before 'l2'
   55 |                 ll l2=1,r2=range+5;
      |                   ^~~
      |                   ;
index.cpp:56:27: error: 'r2' was not declared in this scope
   56 |                 while (l2<r2){
      |                           ^~
index.cpp:56:24: error: 'l2' was not declared in this scope
   56 |                 while (l2<r2){
      |                        ^~
index.cpp:57:27: error: expected ';' before 'm'
   57 |                         ll m = l2+(r2-l2)/2;
      |                           ^~
      |                           ;
index.cpp:58:39: error: 'm' was not declared in this scope; did you mean 'tm'?
   58 |                         if (r2-l2==1) m=r2;
      |                                       ^
      |                                       tm
index.cpp:59:54: error: 'm' was not declared in this scope; did you mean 'tm'?
   59 |                         if(query(1, 0,n-1, l-1, r-1, m) >= m) l2=m;
      |                                                      ^
      |                                                      tm
index.cpp:62:25: error: 'l2' was not declared in this scope
   62 |                 cout << l2 << "\n";
      |                         ^~