제출 #1347743

#제출 시각아이디문제언어결과실행 시간메모리
1347743Muhammad_AneeqWeighting stones (IZhO11_stones)C++20
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
using namespace std;
struct query
{
    set<int>a;//available from other side
    set<int>le;//leftovers
    set<int>b;//used
    map<int,int>pr;
    void upd()
    {
        while (le.size())
        {
            int f1=*le.begin();
            auto z=a.lower_bound(f1);
            // cout<<f1<<endl;
            if (z!=a.end())
            {
                int f=*z;
                pr[f1]=f;
                b.insert(f1);
                a.erase(f);
                le.erase(f1);
            }
            else
                break;
        }
    }
    void ins(int x)
    {
        auto z=a.lower_bound(x);
        if (z==a.end())
            le.insert(x);
        else
        {
            int f=*z;
            pr[x]=f;
            b.insert(x);
            a.erase(f);
        }
        // upd();
    }
    void ins1(int x)
    {
        auto z=b.lower_bound(x);
        if (z==begin(b))
            a.insert(x);
        else
        {
            z--;
            int f=*z;
            if (pr[f]<x)
                a.insert(x);
            else
            {
                a.insert(pr[f]);
                pr[f]=x;
            }
        }
        // if (x==3)
        //     cout<<"fah\n";
        upd();
    }
};
inline void solve()
{
    int n;
    cin>>n;
    query ans[2]={};
    for (int i=0;i<n;i++)
    {
        int r,s;
        cin>>r>>s;
        s--;
        ans[s].ins(r);
        ans[1-s].ins1(r);
        bool w=ans[0].le.size(),x=ans[1].le.size();
        if (w&&x)
            cout<<"?\n";
        else if (w)
            cout<<">\n";
        else
            cout<<"<\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t=1;
    // cin>>t;
    for (int i=1;i<=t;i++)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...