我最开始的代码检查了好几遍就是过不了样例,后来看了看讨论区似乎有与我一样的问题,我写了一个快读就过了
最开始的代码
while(m--) {
cin>>ch;
if(ch=='Q') {
scanf("%d%d",&q[++tot].l,&q[tot].r);
q[tot].t=cnt,q[tot].id=tot;
} else {
scanf("%d%d",&re[++cnt].ori,&re[cnt].dis);
}
}
应该是在scanf中++tot的问题,具体我也不太清楚
改成如下方式就可以了read()是我写的快读
while(m--) {
cin>>ch;
if(ch=='Q') {
q[++tot].l=read();
q[tot].r=read();
q[tot].t=cnt,q[tot].id=tot;
} else {
re[++cnt].ori=read();
re[cnt].dis=read();
}
}