# include<stdio.h>
# include<stdlib.h>
# include<iostream>
# include<string>
# include<sstream>
# include<vector>
using namespace std;
struct Summon
{ int health;
int attack;
};
vector<Summon> player[2];//0是先手玩家,1是后手玩家
int main()
{
//freopen("data.txt","r",stdin);
int n;
cin>>n;
getchar();
int player_order = 0;//用来表示先手玩家与后手玩家的操作
stringstream ss;
string temp;
//初始化英雄攻击力和血量
Summon temp_s;
temp_s.attack = 0;
temp_s.health = 30;
player[0].push_back(temp_s);
player[1].push_back(temp_s);
while(n--)
{
getline(cin,temp);
if(temp == "end")
{
player_order++;
continue;
}
else
{
ss.str(temp);
ss>>temp;
int po = player_order & 1;//取余操作,获得该回合操作玩家的编号
int po_com = 1 - po;//对手编号
if(temp=="summon")
{
int pos;
ss>>pos>>temp_s.attack>>temp_s.health;
ss.clear();
vector<Summon>::iterator it = player[po].begin();
player[po].insert(it+pos,temp_s);
}
else if(temp == "attack")
{
int attacker;
int defender;
ss>>attacker>>defender;
ss.clear();
player[po][attacker].health -= player[po_com][defender].attack;
player[po_com][defender].health -= player[po][attacker].attack;
if(player[po][attacker].health<=0)
{
vector<Summon>::iterator it = player[po].begin();
player[po].erase(it+attacker);
}
if(defender!=0&&player[po_com][defender].health<=0)
{
vector<Summon>::iterator it = player[po_com].begin();
player[po_com].erase(it+defender);
}
}
}
}
int win=0;
if(player[0][0].health <= 0)
win = -1;
else if(player[1][0].health <= 0)
win = 1;
int num_0,num_1;
num_0 = player[0].size()-1;
num_1 = player[1].size()-1;
cout<<win<<endl;
cout<<player[0][0].health<<endl;
cout<<num_0<<" ";
for(int i=1;i<=num_0;i++)
cout<<player[0][i].health<<" ";
cout<<endl;
cout<<player[1][0].health<<endl;
cout<<num_1<<" ";
for(int i=1;i<=num_1;i++)
cout<<player[1][i].health<<" ";
return 0;
}
CCF CSP 201609-3 满分AC
最新推荐文章于 2024-11-22 18:54:57 发布