ccf 炉石传说 模拟
来源:互联网 发布:大众软件pdf 编辑:程序博客网 时间:2024/05/17 02:47
这道题,我用的是vector来模拟战场,vector可以任意的操作和删除,所以用起来很方便。。。
100分代码:
#include<stdio.h>#include<iostream>#include<string.h>#include<vector>using namespace std;int x=30,y=30;//先手英雄 后手英雄struct act{ int pos; int att; int live; act(int poss,int attt,int livee) { pos=poss; att=attt; live=livee; }};vector<act>v0,v1;//先手战场 后首战场void update(){ for(int i=0; i<v0.size(); i++) { act k=v0[i]; if(k.live<=0)v0.erase(v0.begin()+i); } for(int i=0; i<v1.size(); i++) { act k=v1[i]; if(k.live<=0)v1.erase(v1.begin()+i); }}void buid(int flag,act a){ if(flag==0) { v0.insert(v0.begin()+a.pos-1,1,a); } else { v1.insert(v1.begin()+a.pos-1,1,a); }}void gg(int flag,int a,int b){ if(flag==0) { if(b==0) { y-=v0[a-1].att; } else { v0[a-1].live-=v1[b-1].att; v1[b-1].live-=v0[a-1].att; } } else { if(b==0) { x-=v1[a-1].att; } else { v1[a-1].live-=v0[b-1].att; v0[b-1].live-=v1[a-1].att; } } update();}int main(){ v0.clear(); v1.clear(); int n; scanf("%d",&n); int flag=0;//先手状态 string s; int a,b,c; for(int i=0; i<n; i++) { cin>>s; if(s=="end") { flag=!flag; continue; } else if(s=="summon") { scanf("%d%d%d",&a,&b,&c); if(x<=0||y<=0)continue; if(flag==0) { if(v0.size()==7)continue; } else { if(v1.size()==7)continue; } buid(flag,act(a,b,c)); } else if(s=="attack") { scanf("%d%d",&a,&b); if(x<=0||y<=0)continue; gg(flag,a,b); } } update(); if(x<=0) printf("-1\n"); else if(y<=0) printf("1\n"); else printf("0\n"); cout<<x<<endl; cout<<v0.size(); for(int i=0; i<v0.size(); i++) { cout<<" "<<v0[i].live; } cout<<endl; cout<<y<<endl; cout<<v1.size(); for(int i=0; i<v1.size(); i++) { cout<<" "<<v1[i].live; } cout<<endl;}
阅读全文
0 0
- CCF 炉石传说 <模拟>
- ccf 炉石传说 模拟
- 【CCF 炉石传说 模拟题】
- CCF 炉石传说
- CCF炉石传说
- ccf 炉石传说
- CCF-炉石传说
- CCF-炉石传说
- CCF炉石传说
- CCF炉石传说
- CCF-炉石传说
- CCF 炉石传说
- ccf炉石传说
- ccf 炉石传说
- ccf 炉石传说
- CCF 201609-3 炉石传说 解题报告 模拟
- 炉石传说-CCF往届题
- ccf试题 炉石传说
- JavaScript入门篇--请做好准备
- 表达式求值(多函数问题)
- 成千上万各行各业资料
- js排序算法详解-归并排序
- python几个语言特性
- ccf 炉石传说 模拟
- 27. Remove Element
- 数
- js排序算法详解-快速排序
- JDBC连接MySQL5.7
- session内置对象
- Android小白进阶(一)--自定义控件之组合控件
- 项目主页布局
- hdu 6006(java 大数,三角形的外心)