QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#405811#3299. Advertisement MatchingLynkcatWA 29ms23220kbC++202.5kb2024-05-06 13:51:062024-05-06 13:51:07

Judging History

你现在查看的是最新测评结果

  • [2024-05-06 13:51:07]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:23220kb
  • [2024-05-06 13:51:06]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
// #define N 
using namespace std;
const int N=250005,L=250000;
int n,m,a[N],b[N],c[N],Q;
int s[N];
namespace seg
{
    int tr[N<<2],tag[N<<2];
    void ptag(int k,int x)
    {
        tag[k]+=x;
        tr[k]+=x;
    }
    void pushup(int k)
    {
        tr[k]=min(tr[k<<1],tr[k<<1|1])+tag[k];
    }
    void update(int k,int l,int r,int L,int R,int x)
    {
        if (L>R)return;
        if (L<=l&&r<=R)
        {
            ptag(k,x);
            return;
        }
        int mid=l+(r-l)/2;
        if (L<=mid) update(k<<1,l,mid,L,R,x);
        if (R>mid) update(k<<1|1,mid+1,r,L,R,x);
        pushup(k);
    }
}
void BellaKira()
{
    int rev=0;

    cin>>n>>m;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    for (int i=1;i<=m;i++)
        cin>>b[i];

    swap(n,m);
    for (int i=1;i<=max(n,m);i++) swap(a[i],b[i]);
    rev=1;

    for (int i=1;i<=n;i++)
    {
        s[a[i]]++;
    }
    for (int i=L;i>=1;i--)
    {
        s[i]+=s[i+1];
        seg::update(1,1,L,i,L,s[i]);
    }
    for (int i=1;i<=m;i++) c[i]=b[i];
    sort(c+1,c+n+1);
    for (int i=1;i<=m;i++)
    {
        seg::update(1,1,L,i,L,-c[n-i+1]);
    }
    // cout<<"???"<<seg::tr[1]<<'\n';
    cin>>Q;
    while (Q--)
    {
        int op,x;
        cin>>op>>x;
        op--;
        op^=rev;
        op++;
        if (op==1)
        {
            a[x]++;
            seg::update(1,1,L,a[x],L,1);
        } else
        if (op==2)
        {
            seg::update(1,1,L,a[x],L,-1);
            a[x]--;
        } else
        if (op==3)
        {
            int v=b[x];
            int pos=upper_bound(c+1,c+n+1,v)-c-1;
            c[pos]++;
            b[x]++;
            seg::update(1,1,L,pos,L,-1);
        } else
        {
            int v=b[x];
            int pos=upper_bound(c+1,c+n+1,v-1)-c;
            c[pos]--;
            b[x]--;
            seg::update(1,1,L,pos,L,1);
        }
        if (seg::tr[1]<0) cout<<0<<'\n';
        else cout<<1<<'\n';
    }

}
signed main()
{
    IOS;
    cin.tie(0);
    int T=1;
    while (T--)
    {
        BellaKira();
    }
}
/*list:
1.mod 998244353 or 1e9+7 or ???
2.N
3.duipai shuju xingtai duoyidian
...
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 23ms
memory: 23220kb

input:

5 5
1 5 2 4 3
3 3 3 3 3
5
4 2
3 5
2 2
1 1
1 4

output:

0
1
1
1
0

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 26ms
memory: 21180kb

input:

100 100
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 1...

output:

1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #3:

score: -100
Wrong Answer
time: 29ms
memory: 21180kb

input:

100 100
42 28 42 64 42 29 72 64 72 29 28 72 28 72 29 42 64 42 72 29 64 29 72 28 42 64 72 64 28 42 72 42 29 64 72 64 72 29 72 29 64 42 64 72 29 28 42 64 72 64 72 28 42 64 64 42 64 64 28 28 72 29 28 64 28 64 64 72 64 28 42 29 64 42 64 42 72 64 64 64 28 64 42 72 64 29 64 29 64 64 72 29 29 28 42 72 64 7...

output:

0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0

result:

wrong answer 2nd lines differ - expected: '0', found: '1'