Submission #74979

# Submission time Handle Problem Language Result Execution time Memory
74979 2018-09-07T20:22:42 Z Vardanyan Weighting stones (IZhO11_stones) C++14
0 / 100
3 ms 376 KB
//#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
const int N = 100*1000+7;
int t[3][4*N];
int f[4*N];
void push(int v,int s,int e){
    t[1][v]+=((e-s+1)*f[v]);
    t[2][v]+=((e-s+1)*f[v]);
    if(s!=e){
        f[2*v]+=f[v];
        f[2*v+1]+=f[v];
    }
    f[v] = 0;
}
void update(int v,int s,int e,int l,int r,int val){
    push(v,s,e);
    if(l>r) return;
    if(s == l && e == r){
        f[v]+=val;
        return;
    }
    int m = (s+e)/2;
    update(v*2,s,m,l,min(m,r),val);
    update(v*2+1,m+1,e,max(l,m+1),r,val);
    push(v*2,s,m);
    push(v*2+1,m+1,e);
    t[1][v] = max(t[1][v*2],t[1][v*2+1]);
    t[2][v] = min(t[2][v*2],t[2][v*2+1]);
}
int main(){
    int n;
    scanf("%d",&n);

    for(int i = 1;i<=n;i++){
        int r,s;
        scanf("%d%d",&r,&s);
        if(s == 1) update(1,1,n,1,r,1);
        else update(1,1,n,1,r,-1);
        push(1,1,n);
        if(t[1][1]>0 && t[2][1]<0){
            printf("?\n");
            continue;
        }
        if(t[1][1]>=0 && t[2][1]>=0){
            printf(">\n");
            continue;
        }
        printf("<\n");
    }
    return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
stones.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&r,&s);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -