F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
Notice:1:五月份月赛定于5.27日12:30--17:30,欢迎大家来玩! 2:关于OJ的注册可看https://www.lydsy.com/JudgeOnline/wttl/thread.php?tid=5671
大视野在线测评-欢迎您
[ New Thread ]
Problem 1012 >> 【求助】别的OJ AC,BZOJ RE?
YoungNeal @ 2018-02-14 19:59:38
[ Quote ] [ Edit ] [ Delete ] 1#
贴代码
#include<cstdio>
#include<iostream>
#define N 200005
using namespace std;

string a;
int m,p;
int top,cnt,last;
int stk[N],val[N];

int main(){
scanf("%d%d",&m,&p);
for(int i=1;i<=m;i++){
int x;
cin>>a>>x;
if(a=="A"){
x=(x+last)%p;
while(top&&x>stk[top]) top--;
stk[++top]=x;
val[top]=++cnt;
}
else{
if(x==0){
printf("0\n");
last=0;
continue;
}
int l=1,r=top,ans;
while(l<=r){
int mid=l+r>>1;
if(cnt-x+1<=val[mid])
ans=mid,r=mid-1;
else
l=mid+1;
}
last=stk[ans];
printf("%d\n",stk[ans]);
}
}
return 0;
}
wdmmsyf @ 2018-02-17 21:04:40
[ Quote ] [ Edit ] [ Delete ] 2#
代码明显有问题,你别的OJ是怎么A的。。
19992147 @ 2018-02-17 22:11:16
[ Quote ] [ Edit ] [ Delete ] 3#
stl @ 2018-02-18 00:18:40
[ Quote ] [ Edit ] [ Delete ] 4#
cin一时爽
EdwardFrog @ 2018-02-18 10:21:08
[ Quote ] [ Edit ] [ Delete ] 5#
RE火葬场
jjikkollp @ 2018-02-21 14:36:54
[ Quote ] [ Edit ] [ Delete ] 6#
早日不用cin
zP1nG @ 2018-02-21 22:08:38
[ Quote ] [ Edit ] [ Delete ] 7#
您代码没什么问题,把cin改成scanf轻松AC。
YoungNeal @ 2018-02-22 19:33:59
[ Quote ] [ Edit ] [ Delete ] 8#
啊谢谢各位大神
果然把cin换成scanf就AC了
谢谢谢谢~
撒花~
[Top] [Previous Page] [Next Page]

HOME Back