Submission #171059

# Submission time Handle Problem Language Result Execution time Memory
171059 2019-12-27T09:05:35 Z mosiashvililuka Simple game (IZhO17_game) C++14
0 / 100
7 ms 504 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,f[100009],tp,fen[200009],kk,zx,xc;
pair <int, int> p[100009];
map <int, int> m;
map <int, int>::iterator it;
void upd(int q, int w){
    while(q<=kk){
        fen[q]+=w;
        q=q+(q&(-q));
    }
}
int read(int q){
    int jm=0;
    while(q>=1){
        jm+=fen[q];
        q=q-(q&(-q));
    }
    return jm;
}
void mak(int q){
    if(q<1) return;
    if(f[q]<=f[q+1]){
        upd(f[q],-1);
        upd(f[q+1],1);
    }else{
        upd(f[q+1]+1,-1);
        upd(f[q]+1,1);
    }
}
void makt(int q){
    if(q<1) return;
    if(f[q]<=f[q+1]){
        upd(f[q],1);
        upd(f[q+1],-1);
    }else{
        upd(f[q+1]+1,1);
        upd(f[q]+1,-1);
    }
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    //scanf("%d%d\n",&a,&b);
    for(i=1; i<=a; i++){
        cin>>f[i];
        //scanf("%d",&f[i]);
        m[f[i]]=1;
    }
    f[a+1]=f[a]+1;
    for(i=1; i<=b; i++){
        //scanf("%d",&tp);
        cin>>tp;
        if(tp==2){
            //scanf("%d\n",&c);
            cin>>c;
            d=0;
            for(int q=1; q<=a; q++){
                if(f[q]<=f[q+1]){
                    zx=f[q];xc=f[q+1];
                    /*upd(f[q],1);
                    upd(f[q+1],-1);*/
                }else{
                    zx=f[q+1]+1;xc=f[q]+1;
                    /*upd(f[q+1]+1,1);
                    upd(f[q]+1,-1);*/
                }
                if(zx<=c&&c<xc) d++;
            }
            cout<<d<<endl;
        }else{
            //scanf("%d%d\n",&c,&d);
            cin>>c>>d;
            f[c]=d;
        }
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Incorrect 7 ms 504 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Incorrect 7 ms 504 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Incorrect 7 ms 504 KB Output isn't correct
5 Halted 0 ms 0 KB -