QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#272365#6754. Selectionmobbb#WA 1ms7580kbC++172.4kb2023-12-02 17:02:192023-12-02 17:02:20

Judging History

This is the latest submission verdict.

  • [2023-12-02 17:02:20]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7580kb
  • [2023-12-02 17:02:19]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int N=2e5+100;

ll n,m,q;
ll num1[N];
ll num2[N];
ll sex[N];
set<ll,greater<ll>> all,G;
ll girl=-1;

    int main(void)
    {
        cin>>n>>m>>q;
        for(int i=1;i<=n;i++)
        {
            ll x,idx;   cin>>x>>idx;
            if(idx==1)
                girl=max(girl,x),G.insert(x);
            all.insert(x);
            num1[x]=i;
            num2[i]=x;
            sex[i]=idx;
        }

        for(int i=1;i<=q;i++)
        {
            ll op;  cin>>op;
            if(op==1)
            {
                ll x,b; cin>>x>>b;
                if(sex[x]!=b)
                {
                    if(b==1) {
                        G.insert(num2[x]);
                        for(auto T_T:G)
                        {
                            girl=T_T;
                            break;
                        }
                    }
                    else {
                        if(num2[x]==girl)
                            girl=-1;
                        G.erase(num2[x]);
                        for(auto T_T:G)
                        {
                            girl=T_T;
                            break;
                        }
                    }
                    sex[x]=b;
                }
            }
            else
            {
//                cout<<girl.size()<<" ha "<<boy.size()<<endl;
                ll x;   cin>>x;
                if(num2[x]==girl)
                    cout<<"1\n";
                else
                {
                    ll win_idx=m;
                    if(girl!=-1)
                        win_idx--;
                    bool flag=false;
                    for(auto T_T:all)
                    {
//                        cout<<T_T<<endl;
                        if(T_T==num2[x])
                        {
                            flag=true;
                            break;
                        }
                        if(T_T!=girl)
                            win_idx--;
                        if(win_idx==0)
                            break;
                    }
                    if(flag)
                        cout<<"1\n";
                    else
                        cout<<"0\n";
                }
            }
        }
        return 0;
    }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5452kb

input:

3 2 3
3 0
1 1
2 0
2 2
1 2 0
2 2

output:

1
0

result:

ok 2 number(s): "1 0"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 7580kb

input:

1000 1 1000
617 0
199 0
776 0
536 1
258 0
311 1
579 0
844 0
356 1
587 0
564 0
782 0
37 1
717 1
612 1
245 1
444 1
750 0
52 1
92 1
741 0
266 1
71 1
189 1
419 1
580 1
585 1
268 1
255 0
490 1
70 1
497 1
829 1
469 1
641 0
929 1
379 1
507 0
474 1
407 0
221 1
985 0
815 1
217 0
445 1
386 0
132 0
154 0
736 1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

wrong answer 1st numbers differ - expected: '0', found: '1'