【CCF 炉石传说 模拟题】
来源:互联网 发布:范蠡网络是个空壳公司 编辑:程序博客网 时间:2024/04/28 01:12
按照题目说的进行模拟操作就好了,注意维护slave队列
刚开始的时候wa了,因为在对死亡者进行pop的时候,可能死亡的是英雄,那等到显示slave的时候就会越界
#include <cstdio>#include <string>#include <iostream>using namespace std;class slave{public: int h, a; slave(){} slave(int hh, int aa){h=hh,a=aa;}};class person{public: int num; slave* que[10]; person(){num = 0;que[0]=new slave(30,0);} void push(int pos,int at, int hl) { if(pos<=num) { for(int i=num+1;i>pos;i--) que[i]=que[i-1]; } num++; que[pos]=new slave(hl, at); } void pop(int pos) { for(int i=pos;i<num;i++) que[i]=que[i+1]; que[num--]=NULL; } void out() { for(int i=1;i<=num;i++) cout<<que[i]->h<<" "<<que[i]->a<<endl; }};int main(){ int n; while(cin>>n) { int now = 0; person s[2]; while(n--) { string op; cin>>op; int a,b,c; if(op=="summon") { cin>>a>>b>>c; s[now].push(a,b,c); } else if(op=="attack") { cin>>a>>b; //at,def slave* me, *you; for(int i=0;i<=s[now].num;i++) if(i==a) me=s[now].que[i]; for(int i=0;i<=s[!now].num;i++) if(i==b) you = s[!now].que[i]; me->h-=you->a; you->h-=me->a; if(me->h<=0 && a) s[now].pop(a); if(you->h<=0 && b) s[!now].pop(b); } else if(op=="end") { now=!now; } } if(s[0].que[0]->h>0&&s[1].que[0]->h>0) cout<<0<<endl; else if(s[0].que[0]->h<=0) cout<<-1<<endl; else if(s[1].que[0]->h<=0) cout<<1<<endl; for(int i=0;i<2;i++) { cout<<s[i].que[0]->h<<endl; cout<<s[i].num<<" "; for(int j=1;j<=s[i].num;j++) cout<<s[i].que[j]->h<<" "; cout<<endl; } } return 0;}
0 0
- 【CCF 炉石传说 模拟题】
- CCF 炉石传说 <模拟>
- ccf 炉石传说 模拟
- CCF 炉石传说
- CCF炉石传说
- ccf 炉石传说
- CCF-炉石传说
- CCF-炉石传说
- CCF炉石传说
- CCF炉石传说
- CCF-炉石传说
- CCF 炉石传说
- ccf炉石传说
- ccf 炉石传说
- ccf 炉石传说
- CCF 201609-3 炉石传说 解题报告 模拟
- CCF CSP 2016年9月第3题 炉石传说(模拟)
- 炉石传说-CCF往届题
- 查看cmake的模块,了解其工作流程
- Android开发心得
- centos7 经常断网
- 查看Oracle性能差的SQL
- Android利用canvas画各种图形(点、直线、弧、圆、椭圆、文字、矩形、多边形、曲线、圆角矩形)
- 【CCF 炉石传说 模拟题】
- 未启动的应用无法监听到系统广播
- 安卓app 框架
- 读文件转义报错String path = " E:/home/product/logs/(fsof_1)/src/application/logs/(1.*.txt | 2.*.txt)"; //不
- 安卓底层开发学习经验第十期
- 代码改变字体颜色/大小
- delphi excel插件重复新创工程
- tomcat架构:核心架构模块
- 关于console.log