답안 #881925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
881925 2023-12-02T09:23:10 Z vjudge1 돌 무게 재기 (IZhO11_stones) C++17
100 / 100
39 ms 9964 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();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9820 KB Output is correct
2 Correct 5 ms 9820 KB Output is correct
3 Correct 5 ms 9744 KB Output is correct
4 Correct 5 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 5 ms 9820 KB Output is correct
7 Correct 5 ms 9820 KB Output is correct
8 Correct 5 ms 9716 KB Output is correct
9 Correct 5 ms 9680 KB Output is correct
10 Correct 8 ms 9672 KB Output is correct
11 Correct 25 ms 9928 KB Output is correct
12 Correct 39 ms 9920 KB Output is correct
13 Correct 31 ms 9816 KB Output is correct
14 Correct 31 ms 9820 KB Output is correct
15 Correct 34 ms 9948 KB Output is correct
16 Correct 34 ms 9820 KB Output is correct
17 Correct 32 ms 9820 KB Output is correct
18 Correct 34 ms 9880 KB Output is correct
19 Correct 33 ms 9820 KB Output is correct
20 Correct 32 ms 9932 KB Output is correct
21 Correct 33 ms 9816 KB Output is correct
22 Correct 35 ms 9820 KB Output is correct
23 Correct 33 ms 9820 KB Output is correct
24 Correct 34 ms 9964 KB Output is correct
25 Correct 39 ms 9820 KB Output is correct