TB 16 10 29 PM
来源:互联网 发布:sublime text 3调试js 编辑:程序博客网 时间:2024/05/29 09:20
T1
80分 最后两个点变态,没有初始序列,然后就不知道怎么输入了。。
前面点不算难,只不过原始序列中有三个同色球在一起的,比较坑,然后就算是模拟了,
string里面有一些奇怪的函数,非常有用。。
str.erase(pos,n); 删除从pos开始的n个字符str.insert(pos,s); 插入
注意在消掉三个球之后看一下是否还可以继续消除
#include<iostream>#include<cstdio>#include<cstring>using namespace std;string c;string a;int n;int main(){ cin>>a; scanf("%d",&n); bool flag=0; for(int i=1;i<=n;i++) { int k; cin>>k>>c; a.insert(k,c); int tot=1; do { flag=0; tot=1; int h=k-1,t=k+1,now=k; while(a[h]==a[now]&&h>=0) { tot++; h--; } h++; while(a[t]==a[now]&&t<a.size()) { tot++; t++; } t--; if(tot>=3) { a.erase(h,tot); flag=1; } k=h; }while(flag==1); if(a.size()==0) cout<<"-"<<endl; else cout<<a<<endl; } return 0;}
T2
做过,记忆犹新
先找到最大的,然后前面的入栈,然后看剩下的最大的在前面还是后面,在前面就不管(在前一个就出栈),在后面的话重复操作,直到栈为空
#include<cstdio>using namespace std;int n,a[1100000],dis[1100000],pos[1100000],stc[1100000],posm=-1,max1=-1;int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=n;i>=1;i--) { if(a[i]>max1) { posm=i; max1=a[i]; } dis[i]=max1; pos[i]=posm; } int tail=1; int top=1; while(tail<=n) { if(dis[tail]>stc[top]) while(tail<=pos[tail]-1) { top++; stc[top]=a[tail]; tail++; } printf("%d ",a[tail]); tail=pos[tail]+1; while(dis[tail]<stc[top]) { printf("%d ",stc[top]); top--; } } return 0;}
阅读全文
0 0
- TB 16 10 29 PM
- TB 16 10 29 AM
- TB
- pm
- PM
- PM
- PM
- pm
- PM
- CentOS分区大于2TB的磁盘以及格式化大于16TB分区的解决方案
- Linux下搭建大于16TB的磁盘阵列步骤
- 磁盘大于16TB如何做ext4的文件系统
- Windows 10完美识别3TB硬盘实录
- 哈哈哈,我的10TB数据卷回来了!
- TB TEST
- 试用TB
- tb测试
- TB测试
- bzoj1061: [Noi2008]志愿者招募(最小费用最大流)
- Maven(总结)深入浅谈。
- VTK学习(一)SetInputData()和SetInputConnection()替换SetInput()
- UVA
- 设计模式
- TB 16 10 29 PM
- BP神经网络
- 论文投稿技巧有哪些
- Json编辑器
- 洛谷P1726 上白泽慧音(强连通分量)
- 操作纪录 | 上传代码到github
- 图像翻正以及原地(不开辟新空间)顺时旋转90度问题
- Kaggle 入门:探索泰坦尼克号事故幸存情况分析
- 图像识别前处理---学习(1)