Submission #476478

# Submission time Handle Problem Language Result Execution time Memory
476478 2021-09-27T10:04:46 Z neki Index (COCI21_index) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
#define loop(i, a, b) for(ll i=a;i<b;++i)
#define pool(i, a, b) for(ll i=a-1;i>=b;--i)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 500100
#define par pair<ll, ll>
#define ld long double
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, q;cin >> n >> q;
    
    vc<vc<ll>> tr(2 * n);
    loop(i, 0, n) {ll t;cin >> t;tr[i+n].eb(t);}
    pool(i, n, 1) tr[i].resize(tr[i * 2].size() + tr[i * 2 + 1].size());
    pool(no, n, 1) merge(all(tr[no * 2]), all(tr[no * 2 +1]), tr[no].begin());
    
    /*loop(i, 1, 2 * n){
        cout << i <<": ";
        fore(v, tr[i]) cout << v<<" ";cout << endl;
    }
    cout << endl;*/
    
    vc<vc<ll>> prno(q);
    loop(i, 0, q){
        ll l, r;cin >> l >> r;--l;
        for(l+=n, r+=n;l<r;l>>=1, r>>=1){
            if(l&1) prno[i].ps(l++);
            if(r&1) prno[i].ps(--r);
        }
        //fore(v, prno[i]) cout << v<<" ";cout <<endl;
    }
    
    vc<ll> l(q, 0), r(q, n);
    while(1){
        ll br=1;
        loop(i, 0, q) if(l[i]<r[i]) br=0;
        if(br) break;
        
        vc<vc<par>> ques(2 * n);
        vc<ll> sum(q, 0);
        loop(i, 0, q) if(l[i]<r[i]){
            ll mid=(l[i]+r[i]+1)/2;
            fore(v, prno[i]) ques[v].eb(mid, i);
        }
        
        loop(i, 1, 2 * n) if(ques[i].size()){
            sort(all(ques[i]), greater<par>());
            loop(j, 0, tr[i].size()) while(ques[i].size() and tr[i][j]>=ques[i].back().fi){
                sum[ques[i].back().se]+=tr[i].size()-j;
                ques[i].pop_back();
            } 
        }
        
        loop(i, 0, q) if(l[i]<r[i]){
            ll mid=(l[i]+r[i]+1)/2;
            if(mid<=sum[i]) l[i]=mid;
            else r[i]=mid-1;
        }
    }
    loop(i, 0, q) cout << l[i] << endl;
}

Compilation message

cc1plus: error: '::main' must return 'int'
index.cpp: In function 'int main()':
index.cpp:27:5: error: 'll' was not declared in this scope; did you mean 'all'?
   27 |     ll n, q;cin >> n >> q;
      |     ^~
      |     all
index.cpp:27:20: error: 'n' was not declared in this scope; did you mean 'yn'?
   27 |     ll n, q;cin >> n >> q;
      |                    ^
      |                    yn
index.cpp:27:25: error: 'q' was not declared in this scope
   27 |     ll n, q;cin >> n >> q;
      |                         ^
index.cpp:29:11: error: template argument 2 is invalid
   29 |     vc<vc<ll>> tr(2 * n);
      |           ^~
index.cpp:29:13: error: template argument 1 is invalid
   29 |     vc<vc<ll>> tr(2 * n);
      |             ^~
index.cpp:29:13: error: template argument 2 is invalid
index.cpp:30:10: error: expected ';' before 'i'
   30 |     loop(i, 0, n) {ll t;cin >> t;tr[i+n].eb(t);}
      |          ^
index.cpp:3:30: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                              ^
index.cpp:30:10: error: 'i' was not declared in this scope; did you mean 'fi'?
   30 |     loop(i, 0, n) {ll t;cin >> t;tr[i+n].eb(t);}
      |          ^
index.cpp:3:34: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                                  ^
index.cpp:30:22: error: expected ';' before 't'
   30 |     loop(i, 0, n) {ll t;cin >> t;tr[i+n].eb(t);}
      |                      ^~
      |                      ;
index.cpp:30:32: error: 't' was not declared in this scope; did you mean 'tr'?
   30 |     loop(i, 0, n) {ll t;cin >> t;tr[i+n].eb(t);}
      |                                ^
      |                                tr
index.cpp:31:10: error: expected ';' before 'i'
   31 |     pool(i, n, 1) tr[i].resize(tr[i * 2].size() + tr[i * 2 + 1].size());
      |          ^
index.cpp:4:30: note: in definition of macro 'pool'
    4 | #define pool(i, a, b) for(ll i=a-1;i>=b;--i)
      |                              ^
index.cpp:31:10: error: 'i' was not declared in this scope; did you mean 'fi'?
   31 |     pool(i, n, 1) tr[i].resize(tr[i * 2].size() + tr[i * 2 + 1].size());
      |          ^
index.cpp:4:36: note: in definition of macro 'pool'
    4 | #define pool(i, a, b) for(ll i=a-1;i>=b;--i)
      |                                    ^
index.cpp:32:10: error: expected ';' before 'no'
   32 |     pool(no, n, 1) merge(all(tr[no * 2]), all(tr[no * 2 +1]), tr[no].begin());
      |          ^~
index.cpp:4:30: note: in definition of macro 'pool'
    4 | #define pool(i, a, b) for(ll i=a-1;i>=b;--i)
      |                              ^
index.cpp:32:10: error: 'no' was not declared in this scope
   32 |     pool(no, n, 1) merge(all(tr[no * 2]), all(tr[no * 2 +1]), tr[no].begin());
      |          ^~
index.cpp:4:36: note: in definition of macro 'pool'
    4 | #define pool(i, a, b) for(ll i=a-1;i>=b;--i)
      |                                    ^
index.cpp:40:11: error: template argument 2 is invalid
   40 |     vc<vc<ll>> prno(q);
      |           ^~
index.cpp:40:13: error: template argument 1 is invalid
   40 |     vc<vc<ll>> prno(q);
      |             ^~
index.cpp:40:13: error: template argument 2 is invalid
index.cpp:41:10: error: expected ';' before 'i'
   41 |     loop(i, 0, q){
      |          ^
index.cpp:3:30: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                              ^
index.cpp:41:10: error: 'i' was not declared in this scope; did you mean 'fi'?
   41 |     loop(i, 0, q){
      |          ^
index.cpp:3:34: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                                  ^
index.cpp:42:11: error: expected ';' before 'l'
   42 |         ll l, r;cin >> l >> r;--l;
      |           ^~
      |           ;
index.cpp:42:24: error: 'l' was not declared in this scope; did you mean 'ld'?
   42 |         ll l, r;cin >> l >> r;--l;
      |                        ^
      |                        ld
index.cpp:42:29: error: 'r' was not declared in this scope; did you mean 'tr'?
   42 |         ll l, r;cin >> l >> r;--l;
      |                             ^
      |                             tr
index.cpp:50:10: error: template argument 2 is invalid
   50 |     vc<ll> l(q, 0), r(q, n);
      |          ^
index.cpp:50:18: error: expression list treated as compound expression in initializer [-fpermissive]
   50 |     vc<ll> l(q, 0), r(q, n);
      |                  ^
index.cpp:50:27: error: expression list treated as compound expression in initializer [-fpermissive]
   50 |     vc<ll> l(q, 0), r(q, n);
      |                           ^
index.cpp:52:11: error: expected ';' before 'br'
   52 |         ll br=1;
      |           ^~~
      |           ;
index.cpp:53:14: error: expected ';' before 'i'
   53 |         loop(i, 0, q) if(l[i]<r[i]) br=0;
      |              ^
index.cpp:3:30: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                              ^
index.cpp:53:14: error: 'i' was not declared in this scope
   53 |         loop(i, 0, q) if(l[i]<r[i]) br=0;
      |              ^
index.cpp:3:34: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                                  ^
index.cpp:53:37: error: 'br' was not declared in this scope; did you mean 'r'?
   53 |         loop(i, 0, q) if(l[i]<r[i]) br=0;
      |                                     ^~
      |                                     r
index.cpp:54:12: error: 'br' was not declared in this scope; did you mean 'r'?
   54 |         if(br) break;
      |            ^~
      |            r
index.cpp:20:13: error: template argument 1 is invalid
   20 | #define par pair<ll, ll>
      |             ^~~~~~~~~~~~
index.cpp:56:15: note: in expansion of macro 'par'
   56 |         vc<vc<par>> ques(2 * n);
      |               ^~~
index.cpp:20:13: error: template argument 2 is invalid
   20 | #define par pair<ll, ll>
      |             ^~~~~~~~~~~~
index.cpp:56:15: note: in expansion of macro 'par'
   56 |         vc<vc<par>> ques(2 * n);
      |               ^~~
index.cpp:56:18: error: template argument 1 is invalid
   56 |         vc<vc<par>> ques(2 * n);
      |                  ^~
index.cpp:56:18: error: template argument 2 is invalid
index.cpp:57:14: error: template argument 2 is invalid
   57 |         vc<ll> sum(q, 0);
      |              ^
index.cpp:57:24: error: expression list treated as compound expression in initializer [-fpermissive]
   57 |         vc<ll> sum(q, 0);
      |                        ^
index.cpp:58:14: error: expected ';' before 'i'
   58 |         loop(i, 0, q) if(l[i]<r[i]){
      |              ^
index.cpp:3:30: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                              ^
index.cpp:58:14: error: 'i' was not declared in this scope
   58 |         loop(i, 0, q) if(l[i]<r[i]){
      |              ^
index.cpp:3:34: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                                  ^
index.cpp:59:15: error: expected ';' before 'mid'
   59 |             ll mid=(l[i]+r[i]+1)/2;
      |               ^~~~
      |               ;
index.cpp:60:41: error: 'mid' was not declared in this scope; did you mean 'mod'?
   60 |             fore(v, prno[i]) ques[v].eb(mid, i);
      |                                         ^~~
index.cpp:10:30: note: in definition of macro 'eb'
   10 | #define eb(...) emplace_back(__VA_ARGS__)
      |                              ^~~~~~~~~~~
index.cpp:63:14: error: expected ';' before 'i'
   63 |         loop(i, 1, 2 * n) if(ques[i].size()){
      |              ^
index.cpp:3:30: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                              ^
index.cpp:63:14: error: 'i' was not declared in this scope
   63 |         loop(i, 1, 2 * n) if(ques[i].size()){
      |              ^
index.cpp:3:34: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                                  ^
index.cpp:64:43: error: template argument 1 is invalid
   64 |             sort(all(ques[i]), greater<par>());
      |                                           ^
index.cpp:65:18: error: expected ';' before 'j'
   65 |             loop(j, 0, tr[i].size()) while(ques[i].size() and tr[i][j]>=ques[i].back().fi){
      |                  ^
index.cpp:3:30: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                              ^
index.cpp:65:18: error: 'j' was not declared in this scope
   65 |             loop(j, 0, tr[i].size()) while(ques[i].size() and tr[i][j]>=ques[i].back().fi){
      |                  ^
index.cpp:3:34: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                                  ^
index.cpp:71:14: error: expected ';' before 'i'
   71 |         loop(i, 0, q) if(l[i]<r[i]){
      |              ^
index.cpp:3:30: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                              ^
index.cpp:71:14: error: 'i' was not declared in this scope
   71 |         loop(i, 0, q) if(l[i]<r[i]){
      |              ^
index.cpp:3:34: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                                  ^
index.cpp:72:15: error: expected ';' before 'mid'
   72 |             ll mid=(l[i]+r[i]+1)/2;
      |               ^~~~
      |               ;
index.cpp:73:16: error: 'mid' was not declared in this scope; did you mean 'mod'?
   73 |             if(mid<=sum[i]) l[i]=mid;
      |                ^~~
      |                mod
index.cpp:77:10: error: expected ';' before 'i'
   77 |     loop(i, 0, q) cout << l[i] << endl;
      |          ^
index.cpp:3:30: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                              ^
index.cpp:77:10: error: 'i' was not declared in this scope
   77 |     loop(i, 0, q) cout << l[i] << endl;
      |          ^
index.cpp:3:34: note: in definition of macro 'loop'
    3 | #define loop(i, a, b) for(ll i=a;i<b;++i)
      |                                  ^