CCF认证2016-09 炉石传说
来源:互联网 发布:照片找回软件 编辑:程序博客网 时间:2024/04/28 07:14
题目链接:http://118.190.20.162/view.page?gpid=T45
一道模拟题,指令都不难处理,要是用Vector来做的话就更方便了
省去了很多操作
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<vector>using namespace std;struct juese{int attack;int hp;juese(){};juese(int a,int b){attack=a;hp=b;}};vector<juese> a,b;int main(){int n,p,q,r;string s;a.push_back(juese(0,30));b.push_back(juese(0,30));scanf("%d",&n);int flag=0,t=0;for(int i=0;i<n;i++){cin>>s;if(s[0]=='s'){scanf("%d%d%d",&p,&q,&r);if(t%2==0) a.insert(a.begin()+p,juese(q,r));else b.insert(b.begin()+p,juese(q,r));}else if(s[0]=='a'){scanf("%d%d",&p,&q);if(t%2==0){a[p].hp-=b[q].attack;b[q].hp-=a[p].attack;if(a[p].hp<=0) {if(p==0) flag=-1;else a.erase(a.begin()+p);}if(b[q].hp<=0) {if(q==0) flag=1;else b.erase(b.begin()+q);}}else{b[p].hp-=a[q].attack;a[q].hp-=b[p].attack;if(a[q].hp<=0) {if(q==0) flag=-1;else a.erase(a.begin()+q);}if(b[p].hp<=0) {if(p==0) flag=1;else b.erase(b.begin()+p);}}}else if(s[0]=='e') t++;}printf("%d\n",flag);printf("%d\n",a[0].hp);printf("%d",a.size()-1);for(int i=1;i<a.size();i++)printf(" %d",a[i].hp);printf("\n");printf("%d\n",b[0].hp);printf("%d",b.size()-1);for(int i=1;i<b.size();i++)printf(" %d",b[i].hp);printf("\n");return 0;}
阅读全文
0 0
- CCF认证2016-09 炉石传说
- CCF认证 201612-3 炉石传说
- ccf认证炉石传说70分错误
- CCF CSP认证2016年9月,NO.3 炉石传说
- CCF 炉石传说
- CCF炉石传说
- ccf 炉石传说
- CCF-炉石传说
- CCF-炉石传说
- CCF炉石传说
- CCF炉石传说
- CCF-炉石传说
- CCF 炉石传说
- ccf炉石传说
- ccf 炉石传说
- ccf 炉石传说
- CCF 炉石传说 <模拟>
- 炉石传说-CCF往届题
- 转-C语言中使用指针与数组的区别
- flask sqlalchemy实现增删改查
- iGH EtherCAT初始化流程分析(二)
- 从上到下打印二叉树(BFS)
- 如何用vs2017打开cuda8工程
- CCF认证2016-09 炉石传说
- [IDA*] ZOJ 2477
- 注解学习笔记
- Activity数据传递详解
- WKWebView与Js实战(OC版)
- CentOS系统找不到setup命令工具的解决方法
- redis之Jedis使用
- LaTeX 中的特殊符号
- 《完美设计模式》之命令模式