Submission #1304662

#TimeUsernameProblemLanguageResultExecution timeMemory
1304662SofiatpcSimple game (IZhO17_game)C11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5+5, MAXH = 1e6;
int bit[MAXH+5], h[MAXN];

void update(int i, int x){
    for(; i <= MAXH; i += i&(-i))
        bit[i] += x;
}

int query(int i){
    int resp = 0;
    for(; i > 0; i -= i&(-i))
        resp += bit[i];
    return resp;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n,m; cin>>n>>m;
    for(int i = 1; i <= n; i++){
        cin>>h[i];
        if(i > 1){ update( min(h[i],h[i-1]), 1); update( max(h[i],h[i-1])+1, -1); }
    }

    for(int i = 1; i <= m; i++){
        int t; cin>>t;
        if(t == 1){
            int pos,val; cin>>pos>>val;
            
            if(pos < n){ update( min(h[pos],h[pos+1]), -1); update( max(h[pos],h[pos+1])+1, 1); }
            if(pos > 1){ update( min(h[pos],h[pos-1]), -1); update( max(h[pos],h[pos-1])+1, 1); }

            h[pos] = val;

            if(pos < n){ update( min(h[pos],h[pos+1]), 1); update( max(h[pos],h[pos+1])+1, -1); }
            if(pos > 1){ update( min(h[pos],h[pos-1]), 1); update( max(h[pos],h[pos-1])+1, -1); }
        }else{
            int x; cin>>x;
            cout<<query(x)<<"\n";
        }
    }
}   

Compilation message (stderr)

game.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.