sdut 3567 模拟
来源:互联网 发布:java布尔类型默认值 编辑:程序博客网 时间:2024/06/05 04:34
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<map>using namespace std;struct node{ int l,r; string ss;}str[20005];char tp[20005],s[20005],c;int cnt,pos,t;void init(){ c=cnt=pos=0; memset(s,0,sizeof(s));}void name(char *tp){ int num=0,i=0; string temp=""; for(i=0;tp[i]!='[';i++) temp+=tp[i]; for(++i;tp[i]!=']';i++) num=num*10+tp[i]-'0'; str[cnt].l=pos; str[cnt].r=pos+num; pos+=num; str[cnt++].ss=temp;}void gets(){ int i,j; scanf("%s",tp); getchar(); for(i=0;i<cnt;i++) if(tp==str[i].ss) { gets(tp); int st=str[i].l,ed=str[i].r; for(j=0;tp[j];j++) { if(st+j>=ed) break; s[st+j]=tp[j]; } if(st+j<ed) s[st+j]=0; return; }}void puts(){ int i,j; scanf("%s",tp); for(i=0;i<cnt;i++) if(tp==str[i].ss) { printf("%s\n",s+str[i].l); return; }}int main(){ scanf("%d",&t); while(t--) { init(); scanf("%s",tp); while(c!='\n'&&scanf("%s%c",tp,&c)!=EOF) name(tp); while(scanf("%s",tp)!=EOF) if(tp[0]=='g') gets(); else if(tp[0]=='c') puts(); else if(tp[0]=='r') { scanf("%s",tp); break; } } return 0;}
0 0
- sdut 3567 模拟
- sdut 3567 Memory Leak 模拟
- SDUT 1133 模拟计算器
- 模拟SDUT OJ登陆
- SDUT—2057 模拟题
- SDUT 3183 (More) Multiplication(模拟)
- sdut-2156(模拟,bfs)
- SDUT 2167 Mathman Bank 模拟
- 【MAP模拟】SDUT 1471 A + B problem
- SDUT 2087 离散事件模拟-银行管理
- sdut 2624 Contest Print Server (模拟)
- SDUT 3165 Round Robina(模拟)
- SDUT 2411 Pixel density(模拟,字符串)
- SDUT 2087 离散事件模拟-银行管理
- 离散事件模拟-银行管理 SDUT
- sdut 3260 Single Round Math 模拟
- SDUT 3545 装备合成 (模拟) -- 解题报告
- SDUT 2087 离散事件模拟-银行管理
- 多项式和伯努利朴素贝叶斯文本分类模型 java实现
- efi bios
- MySQL之选择字段数据类型
- POJ 3096-Surprising Strings(map-相同串)
- 关于图像压缩的相关知识
- sdut 3567 模拟
- Flume+HDFS+Kafka+Hive实例搭建
- java琐碎知识点410
- Thinkpad E40 F1-12功能键失效
- spring 中 Spring-data-redis的配置与使用
- 图像压缩
- java多线程:13、CountDownLatch同步辅助类【计数器】
- 开发遇到的相对路径和绝对路径问题
- metlab 6