码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj1012

时间:2018-03-18 18:39:21      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:std   inline   top   line   col   include   clu   nbsp   color   

蒟蒻只能AC单调栈的做法了

#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
int a[200004],num[200004];

inline int read(){
    char ch=getchar();int k=0;
    while(!isdigit(ch)) ch=getchar();
    while(isdigit(ch)){k=(k<<1)+(k<<3)+ch-0;ch=getchar();}
    return k;
}

int main(){
    int n=read(),cnt=0,top=0,mod=read(),t=0;
    while(n--){
        char c;scanf(" %c",&c);int x=read();
        if(c==A){
            x=(x+t)%mod;
            num[++cnt]=x;
            while(top&&num[a[top]]<=x)top--;
            a[++top]=cnt;
        }
        else{
            int y=lower_bound(a+1,a+top+1,cnt-x+1)-a;
            t=num[a[y]];
            printf("%d\n",t);
        }
    }
    return 0;
}

 

bzoj1012

标签:std   inline   top   line   col   include   clu   nbsp   color   

原文地址:https://www.cnblogs.com/MikuKnight/p/8596555.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!