Submission #170364

# Submission time Handle Problem Language Result Execution time Memory
170364 2019-12-24T22:17:18 Z rzbt Cake (CEOI14_cake) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define MAXN 250005
#define F first
#define S second
using namespace std;

ll n,a;
ll niz[MAXN];

ll seg[4*MAXN];
ll lazy[4*MAXN];
set<pair<ll,ll> > svi;


void dodaj(ll l,ll d,ll p,ll x,ll k){
    if(l==d){
        seg[k]=x;
        return;
    }
    ll mid=(l+d)/2;
    if(p<=mid)return dodaj(l,mid,p,x,k+k);
    else dodaj(mid+1,d,p,x,k+k+1);
    seg[k]=max(seg[k+k],seg[k+k+1]);
}
ll dobij(ll l,ll d,ll tl,ll td,ll k){
    if(l>td || d<tl)return 0;
    if(l>=tl && d<=td)return seg[k];
    ll mid=(l+d)/2;
    return max(dobij(l,mid,tl,td,k+k),dobij(mid+1,d,tl,td,k+k+1));
}

void izgradi(ll l,ll d,ll k){
    if(l==d){
        seg[k]=niz[l];
        return;
    }
    ll mid=(l+d)/2;
    izgradi(l,mid,k+k);
    izgradi(mid+1,d,k+k+1);
    seg[k]=max(seg[k+k],seg[k+k+1]);
}

bool nadjen;

ll nadjiL(ll l,ll d,ll tl,ll td,ll k,ll x){
    //printf("   %lld %lld   %lld %lld\n",l,d,tl,td);
    if(nadjen)return -1;
    if(l>td || d<tl)return -1;
    ll mid=(l+d)/2;
    if(l>=tl && d<=td){
        if(l==d ){
            if(seg[k]>x)nadjen=true;
            return (seg[k]>x?l:-1);
        }

        if(seg[k+k+1]>x)return nadjiL(mid+1,d,tl,td,k+k+1,x);
        return nadjiL(l,mid,tl,td,k+k,x);
    }

    ll tren=nadjiL(mid+1,d,tl,td,k+k+1,x);
    if(tren!=-1)return tren;
    return nadjiL(l,mid,tl,td,k+k,x);
}

ll nadjiD(ll l,ll d,ll tl,ll td,ll k,ll x){
    //printf("   %lld %lld   %lld %lld\n",l,d,tl,td);
    if(nadjen)return -1;
    if(l>td || d<tl)return -1;
    ll mid=(l+d)/2;
    if(l>=tl && d<=td){
        if(l==d ){
            //printf("                        %lld %lld\n",seg[k],x);
            if(seg[k]>x)nadjen=true;
            return (seg[k]>x?l:-1);
        }
        //printf("                %lld %lld\n",seg[k+k],x);
        if(seg[k+k]>x)return nadjiD(l,mid,tl,td,k+k,x);
        return nadjiD(mid+1,d,tl,td,k+k+1,x);
    }

    ll tren=nadjiD(l,mid,tl,td,k+k,x);
    if(tren!=-1)return tren;
    return nadjiD(mid+1,d,tl,td,k+k+1,x);
}

int main()///PROMENI U LONG LONG
{
    scanf("%lld %lld", &n, &a);
    for(ll i=1;i<=n;i++){
        scanf("%lld",niz+i);
        niz[i]*=500005;
        svi.insert(mp(niz[i],i));
    }
    izgradi(1,n,1);
    ll qq;
    scanf("%lld", &qq);
    while(qq--){
        char qt[5];
        scanf("%s", qt);
        if(qt[0]=='E'){
            ll koji,postaje;
            scanf("%lld %lld", &koji, &postaje);
            svi.erase(mp(niz[koji],koji));
            //printf("  poz %lld brisem %lld ",koji,niz[koji]);
            auto it=svi.end();
            for(ll i=1;i<postaje;i++){
                it--;
                auto tp=*it;
                tp.F++;
                svi.erase(it);
                it=svi.insert(tp).F;
                dodaj(1,n,tp.second,tp.first,1);
                printf("%lld ",tp.S);

            }
            it--;
            niz[koji]=(it->first)+1;
            //printf(" stavljam %lld",niz[koji]);
            svi.insert(mp(niz[koji],koji));
            dodaj(1,n,koji,niz[koji],1);
            //printf("     sada %lld\n",dobij(1,n,koji,koji,1));
        }else{
            ll koji;
            scanf("%lld", &koji);
            if(koji==a){
                printf("0\n");
                continue;
            }
            if(koji<a){
                ll najv=dobij(1,n,koji,a-1,1);
                nadjen=false;
                ll tn=nadjiD(1,n,a+1,n,1,najv);
                if(tn==-1)tn=n+1;
                printf("%lld\n",tn-koji-1);
            }else{
                ll najv=dobij(1,n,a+1,koji,1);
                nadjen=false;
                ll tn=nadjiL(1,n,1,a-1,1,najv);
                if(tn==-1)tn=0;
                printf("%lld\n",koji-tn-1);
            }

        }
    }

    return 0;
}

Compilation message

cake.cpp:10:1: error: 'll' does not name a type; did you mean 'all'?
 ll n,a;
 ^~
 all
cake.cpp:11:1: error: 'll' does not name a type; did you mean 'all'?
 ll niz[MAXN];
 ^~
 all
cake.cpp:13:1: error: 'll' does not name a type; did you mean 'all'?
 ll seg[4*MAXN];
 ^~
 all
cake.cpp:14:1: error: 'll' does not name a type; did you mean 'all'?
 ll lazy[4*MAXN];
 ^~
 all
cake.cpp:15:10: error: 'll' was not declared in this scope
 set<pair<ll,ll> > svi;
          ^~
cake.cpp:15:10: note: suggested alternative: 'all'
 set<pair<ll,ll> > svi;
          ^~
          all
cake.cpp:15:13: error: 'll' was not declared in this scope
 set<pair<ll,ll> > svi;
             ^~
cake.cpp:15:13: note: suggested alternative: 'all'
 set<pair<ll,ll> > svi;
             ^~
             all
cake.cpp:15:15: error: template argument 1 is invalid
 set<pair<ll,ll> > svi;
               ^
cake.cpp:15:15: error: template argument 2 is invalid
cake.cpp:15:17: error: template argument 1 is invalid
 set<pair<ll,ll> > svi;
                 ^
cake.cpp:15:17: error: template argument 2 is invalid
cake.cpp:15:17: error: template argument 3 is invalid
cake.cpp:18:12: error: variable or field 'dodaj' declared void
 void dodaj(ll l,ll d,ll p,ll x,ll k){
            ^~
cake.cpp:18:12: error: 'll' was not declared in this scope
cake.cpp:18:12: note: suggested alternative: 'all'
 void dodaj(ll l,ll d,ll p,ll x,ll k){
            ^~
            all
cake.cpp:18:17: error: 'll' was not declared in this scope
 void dodaj(ll l,ll d,ll p,ll x,ll k){
                 ^~
cake.cpp:18:17: note: suggested alternative: 'all'
 void dodaj(ll l,ll d,ll p,ll x,ll k){
                 ^~
                 all
cake.cpp:18:22: error: 'll' was not declared in this scope
 void dodaj(ll l,ll d,ll p,ll x,ll k){
                      ^~
cake.cpp:18:22: note: suggested alternative: 'all'
 void dodaj(ll l,ll d,ll p,ll x,ll k){
                      ^~
                      all
cake.cpp:18:27: error: 'll' was not declared in this scope
 void dodaj(ll l,ll d,ll p,ll x,ll k){
                           ^~
cake.cpp:18:27: note: suggested alternative: 'all'
 void dodaj(ll l,ll d,ll p,ll x,ll k){
                           ^~
                           all
cake.cpp:18:32: error: 'll' was not declared in this scope
 void dodaj(ll l,ll d,ll p,ll x,ll k){
                                ^~
cake.cpp:18:32: note: suggested alternative: 'all'
 void dodaj(ll l,ll d,ll p,ll x,ll k){
                                ^~
                                all
cake.cpp:28:1: error: 'll' does not name a type; did you mean 'all'?
 ll dobij(ll l,ll d,ll tl,ll td,ll k){
 ^~
 all
cake.cpp:35:14: error: variable or field 'izgradi' declared void
 void izgradi(ll l,ll d,ll k){
              ^~
cake.cpp:35:14: error: 'll' was not declared in this scope
cake.cpp:35:14: note: suggested alternative: 'all'
 void izgradi(ll l,ll d,ll k){
              ^~
              all
cake.cpp:35:19: error: 'll' was not declared in this scope
 void izgradi(ll l,ll d,ll k){
                   ^~
cake.cpp:35:19: note: suggested alternative: 'all'
 void izgradi(ll l,ll d,ll k){
                   ^~
                   all
cake.cpp:35:24: error: 'll' was not declared in this scope
 void izgradi(ll l,ll d,ll k){
                        ^~
cake.cpp:35:24: note: suggested alternative: 'all'
 void izgradi(ll l,ll d,ll k){
                        ^~
                        all
cake.cpp:48:1: error: 'll' does not name a type; did you mean 'all'?
 ll nadjiL(ll l,ll d,ll tl,ll td,ll k,ll x){
 ^~
 all
cake.cpp:68:1: error: 'll' does not name a type; did you mean 'all'?
 ll nadjiD(ll l,ll d,ll tl,ll td,ll k,ll x){
 ^~
 all
cake.cpp: In function 'int main()':
cake.cpp:91:25: error: 'n' was not declared in this scope
     scanf("%lld %lld", &n, &a);
                         ^
cake.cpp:91:25: note: suggested alternative: 'yn'
     scanf("%lld %lld", &n, &a);
                         ^
                         yn
cake.cpp:91:29: error: 'a' was not declared in this scope
     scanf("%lld %lld", &n, &a);
                             ^
cake.cpp:92:9: error: 'll' was not declared in this scope
     for(ll i=1;i<=n;i++){
         ^~
cake.cpp:92:9: note: suggested alternative: 'all'
     for(ll i=1;i<=n;i++){
         ^~
         all
cake.cpp:92:16: error: 'i' was not declared in this scope
     for(ll i=1;i<=n;i++){
                ^
cake.cpp:93:22: error: 'niz' was not declared in this scope
         scanf("%lld",niz+i);
                      ^~~
cake.cpp:95:13: error: request for member 'insert' in 'svi', which is of non-class type 'int'
         svi.insert(mp(niz[i],i));
             ^~~~~~
cake.cpp:97:5: error: 'izgradi' was not declared in this scope
     izgradi(1,n,1);
     ^~~~~~~
cake.cpp:97:5: note: suggested alternative: 'isgraph'
     izgradi(1,n,1);
     ^~~~~~~
     isgraph
cake.cpp:98:5: error: 'll' was not declared in this scope
     ll qq;
     ^~
cake.cpp:98:5: note: suggested alternative: 'all'
     ll qq;
     ^~
     all
cake.cpp:99:20: error: 'qq' was not declared in this scope
     scanf("%lld", &qq);
                    ^~
cake.cpp:104:16: error: expected ';' before 'koji'
             ll koji,postaje;
                ^~~~
cake.cpp:105:33: error: 'koji' was not declared in this scope
             scanf("%lld %lld", &koji, &postaje);
                                 ^~~~
cake.cpp:105:40: error: 'postaje' was not declared in this scope
             scanf("%lld %lld", &koji, &postaje);
                                        ^~~~~~~
cake.cpp:105:40: note: suggested alternative: '_xstate'
             scanf("%lld %lld", &koji, &postaje);
                                        ^~~~~~~
                                        _xstate
cake.cpp:106:17: error: request for member 'erase' in 'svi', which is of non-class type 'int'
             svi.erase(mp(niz[koji],koji));
                 ^~~~~
cake.cpp:106:26: error: 'niz' was not declared in this scope
             svi.erase(mp(niz[koji],koji));
                          ^~~
cake.cpp:108:25: error: request for member 'end' in 'svi', which is of non-class type 'int'
             auto it=svi.end();
                         ^~~
cake.cpp:109:20: error: expected ';' before 'i'
             for(ll i=1;i<postaje;i++){
                    ^
cake.cpp:109:24: error: 'i' was not declared in this scope
             for(ll i=1;i<postaje;i++){
                        ^
cake.cpp:113:21: error: request for member 'erase' in 'svi', which is of non-class type 'int'
                 svi.erase(it);
                     ^~~~~
cake.cpp:114:24: error: request for member 'insert' in 'svi', which is of non-class type 'int'
                 it=svi.insert(tp).F;
                        ^~~~~~
cake.cpp:115:17: error: 'dodaj' was not declared in this scope
                 dodaj(1,n,tp.second,tp.first,1);
                 ^~~~~
cake.cpp:122:17: error: request for member 'insert' in 'svi', which is of non-class type 'int'
             svi.insert(mp(niz[koji],koji));
                 ^~~~~~
cake.cpp:123:13: error: 'dodaj' was not declared in this scope
             dodaj(1,n,koji,niz[koji],1);
             ^~~~~
cake.cpp:126:16: error: expected ';' before 'koji'
             ll koji;
                ^~~~
cake.cpp:127:28: error: 'koji' was not declared in this scope
             scanf("%lld", &koji);
                            ^~~~
cake.cpp:133:20: error: expected ';' before 'najv'
                 ll najv=dobij(1,n,koji,a-1,1);
                    ^~~~
cake.cpp:135:20: error: expected ';' before 'tn'
                 ll tn=nadjiD(1,n,a+1,n,1,najv);
                    ^~
cake.cpp:136:20: error: 'tn' was not declared in this scope
                 if(tn==-1)tn=n+1;
                    ^~
cake.cpp:136:20: note: suggested alternative: 'tm'
                 if(tn==-1)tn=n+1;
                    ^~
                    tm
cake.cpp:137:33: error: 'tn' was not declared in this scope
                 printf("%lld\n",tn-koji-1);
                                 ^~
cake.cpp:137:33: note: suggested alternative: 'tm'
                 printf("%lld\n",tn-koji-1);
                                 ^~
                                 tm
cake.cpp:139:20: error: expected ';' before 'najv'
                 ll najv=dobij(1,n,a+1,koji,1);
                    ^~~~
cake.cpp:141:20: error: expected ';' before 'tn'
                 ll tn=nadjiL(1,n,1,a-1,1,najv);
                    ^~
cake.cpp:142:20: error: 'tn' was not declared in this scope
                 if(tn==-1)tn=0;
                    ^~
cake.cpp:142:20: note: suggested alternative: 'tm'
                 if(tn==-1)tn=0;
                    ^~
                    tm
cake.cpp:143:38: error: 'tn' was not declared in this scope
                 printf("%lld\n",koji-tn-1);
                                      ^~
cake.cpp:143:38: note: suggested alternative: 'tm'
                 printf("%lld\n",koji-tn-1);
                                      ^~
                                      tm
cake.cpp:102:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", qt);
         ~~~~~^~~~~~~~~~