Submission #881953

# Submission time Handle Problem Language Result Execution time Memory
881953 2023-12-02T10:14:50 Z noyancanturk Weighting stones (IZhO11_stones) C++17
100 / 100
42 ms 5580 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    const int lim=1e5+100;
#else
    const int lim=3e3;
#endif

#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define pb push_back

const int mod=1e9+7;
using pii=pair<int,int>;

struct segtree{
    int n,lazy[4*lim];
    pii tree[4*lim];
    segtree(int n):n(n){
        memset(lazy,0,sizeof(lazy));
        fill(tree,tree+4*lim,pii{0,0});
    }
    void push(int node,int l,int r){
        if(!lazy[node])return;
        tree[node].first+=lazy[node];
        tree[node].second+=lazy[node];
        if(l^r){
            int child=node<<1;
            lazy[child]+=lazy[node];
            lazy[child|1]+=lazy[node];
        }
        lazy[node]=0;
    }
    int L,R,VAL;
    pii merge(pii v1,pii v2){
        return pii{min(v1.first,v2.first),max(v1.second,v2.second)};
    }
    pii update(int l,int r,int node){
        push(node,l,r);
        if(r<L||R<l){
            return tree[node];
        }
        if(L<=l&&r<=R){
            lazy[node]+=VAL;
            push(node,l,r);
            return tree[node];
        }
        int mid=(l+r)>>1,child=node<<1;
        return tree[node]=merge(update(l,mid,child),update(mid+1,r,child|1));
    }
    void Update(int l,int r,int val){
        L=l,R=r,VAL=val;
        update(1,n,1);
    }
};

void solve(){
    int n;
    cin>>n;
    segtree a(n);
    for(int i=0;i<n;i++){
        int v,s;
        cin>>v>>s;
        a.Update(1,v,s==1?1:-1);
        if(a.tree[1].first<0&&0<a.tree[1].second){
            cout<<"?\n";
        }else if(a.tree[1].first<0){
            cout<<"<\n";
        }else{
            cout<<">\n";
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
#else
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 3 ms 5156 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 3 ms 4956 KB Output is correct
7 Correct 3 ms 4956 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 5 ms 5168 KB Output is correct
11 Correct 22 ms 5208 KB Output is correct
12 Correct 42 ms 5224 KB Output is correct
13 Correct 32 ms 5212 KB Output is correct
14 Correct 29 ms 5200 KB Output is correct
15 Correct 32 ms 5212 KB Output is correct
16 Correct 32 ms 5304 KB Output is correct
17 Correct 30 ms 5272 KB Output is correct
18 Correct 32 ms 5580 KB Output is correct
19 Correct 34 ms 5224 KB Output is correct
20 Correct 30 ms 5208 KB Output is correct
21 Correct 34 ms 5308 KB Output is correct
22 Correct 34 ms 5264 KB Output is correct
23 Correct 31 ms 5264 KB Output is correct
24 Correct 32 ms 5316 KB Output is correct
25 Correct 31 ms 5252 KB Output is correct