开始没想到用pair (我太菜了)
于是我给AC的数量赋了个权重,即×(罚时的最大值+1),再减去罚时得到权值在splay上排序
splay上的节点编号即为那个人的编号
但是听取WA声一片
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,MAX=1.5e6+1;
const long long INF=9223372036854775807;
unsigned seed,last=7;
int T,n,m,Ria,Rib,root;
int a[N],b[N];
struct node{int ch[2],fa,size;long long val;}t[N];
inline int read(unsigned &seed)
{
seed=seed*17+last;
return seed%m+1;
}
inline void pushup(int x)
{
t[x].size=t[t[x].ch[0]].size+t[t[x].ch[1]].size+1;
}
inline void rotate(int x)
{
int y=t[x].fa,z=t[y].fa;
bool k=(x==t[y].ch[1]);
t[z].ch[y==t[z].ch[1]]=x,t[x].fa=z;
t[y].ch[k]=t[x].ch[!k],t[t[x].ch[!k]].fa=y;
t[x].ch[!k]=y,t[y].fa=x;
pushup(y),pushup(x);
}
inline void splay(int x,int to)
{
while(t[x].fa!=to)
{
int y=t[x].fa,z=t[y].fa;
if(z!=to) rotate((x==t[y].ch[0])^(y==t[z].ch[0])?x:y);
rotate(x);
}
if(!to) root=x;
}
inline int next(int x,bool k)
{
splay(x,0);
x=t[x].ch[k];
while(t[x].ch[!k]) x=t[x].ch[!k];
return x;
}
inline void erase(int x)
{
int l=next(x,0),r=next(x,1);
splay(l,0),splay(r,l);
t[r].ch[0]=0;
splay(r,0);
}
inline void insert(int x,long long val)
{
int u=root;
while(t[u].ch[val>t[u].val]) u=t[u].ch[val>t[u].val];
t[u].ch[val>t[u].val]=x;
t[x]=(node){{0,0},u,1,val};
splay(x,0);
}
int main(void)
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d%u",&m,&n,&seed);
insert(m+1,INF),insert(m+2,-INF);
while(n--)
{
Ria=read(seed),Rib=read(seed);
if(t[Ria].size) erase(Ria);
++a[Ria],b[Ria]+=Rib;
insert(Ria,1ll*a[Ria]*MAX-Rib);
printf("%d\n",last=t[t[root].ch[1]].size-1);
}
memset(t,0,sizeof(t));
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
root=0;
}
return 0;
}
该不会是splay写炸了吧,大雾