[JSOI2008]最大数maxnumber
Description
Input
第一行两个整数,M和D,其中M表示操作的个数(M <= 200,000),D如上文中所述,满足(0
Output
Sample Input
A 96
Q 1
A 97
Q 1
Q 2
Sample Output
96
93
96
用的是并查集,然后用了路径压缩。
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<string> 6 #include<fstream> 7 using namespace std; 8 //ifstream cin("cin.in");ofstream fout("test.out"); 9 10 long long m,mod,f[200005],d[200005],t=0,size=0; 11 12 int cind(int x){ 13 if(x==f[x]) return x; 14 int fx=cind(f[x]); 15 if(d[x]<d[f[x]]) d[x]=d[f[x]]; //小心观看 16 f[x]=fx; 17 return fx; 18 } 19 20 void Q(int x){ 21 int z=size-x+1; 22 cind(z); 23 t=d[z]; 24 cout<<d[z]<<endl; 25 } 26 27 int main() 28 { 29 cin>>m>>mod; 30 char s;int n; 31 for(int i=1;i<=m;++i) 32 { 33 cin>>s>>n; 34 if(s=='Q') Q(n); 35 else {size++;f[size-1]=size;f[size]=size;d[size]=(t+n)%mod;} 36 } 37 // system("pause"); 38 return 0; 39 40 }
转载于:https://www.cnblogs.com/noip/archive/2013/03/19/2969865.html
[JSOI2008]最大数maxnumber相关推荐
- 1012: [JSOI2008]最大数maxnumber
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Submit: 10711 Solved: 4683 [Su ...
- BZOJ-1012[JSOI2008]最大数maxnumber 线段树区间最值
这道题相对简单下面是题目: 1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Submit: 6542 Solve ...
- BZOJ 1012: [JSOI2008]最大数maxnumber 单调队列/线段树/树状数组/乱搞
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Submit: 4750 Solved: 2145 [Sub ...
- BZOJ 1012: [JSOI2008]最大数maxnumber
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Submit: 11358 Solved: 4978 [Su ...
- BZOJ 1012: [JSOI2008]最大数maxnumber(线段树)
裸的线段树...因为数组开小了而一直RE..浪费了好多时间.. -------------------------------------------------------------------- ...
- BZOJ 1012 [JSOI2008]最大数maxnumber
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Submit: 5425 Solved: 2397 [Sub ...
- 【BZOJ 1012】[JSOI2008]最大数maxnumber
1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec Memory Limit: 162 MB Description 现在请求你维护一个数列,要求提供以下两种 ...
- bzoj1012: [JSOI2008]最大数maxnumber [单调队列]
Description 现在请求你维护一个数列,要求提供以下两种操作:1. 查询操作.语法:Q L 功能:查询当前数列中末尾L 个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度.2. ...
- 【听说是线段树】bzoj1012 [JSOI2008]最大数maxnumber
一眼看题目吓了一跳:这TM不就是单调队列吗,200000又怎样,大不了我二分嘛 系统提示:成功开启 手残模式 开始瞎写: 1 #include <cstdio> 2 long long a ...
- 【BZOJ】1012: [JSOI2008]最大数maxnumber 树状数组求区间最值
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1012 题意:维护一个数列,开始时没有数值,之后会有两种操作, Q L :查询数列末 ...
最新文章
- IDEA加密文件Base64转换String传输以及报文摘要MD5防止恶意篡改
- LED音乐频谱之输出数据处理
- java mysql 删除 博客园_mysql的增删改查
- php加载外部html,VUE页面加载外部HTML实例详解
- 稀疏表示介绍(中)、(下)
- Spring boot的场景启动器
- java和tornado_TornadoJ
- c语言调用createthread线程的头文件_易语言API多线程总汇
- werkzeug response
- java 限制文件大小_java上传文件大小限制
- 远距离WiFi模块图传,无线wifi技术方案,CV5200无线传输应用
- C++ gflags
- Detecting Spacecraft Anomalies Using LSTMs and Nonparametric Dynamic Thresholding
- 蓝桥杯——单片机学习(3——点亮LED灯)
- 首批 RISC-V 手机要来了,你准备好了吗?
- jqGrid参数整理
- 在window下查看占用tomcat进程,杀死进程并启用tomcat
- 为将来而记下的过去——扭曲的爱,病态的教育
- python人工智能项目实战 桑塔努·帕塔纳亚克 pdf_(特价书)Python人工智能项目实战...
- pandownload内部测试版