P7610 [THUPC 2021] 群星连结【Updating】

· · 个人记录

#include <algorithm>
#include <iostream>

using namespace std;

struct Character
{
    int id,pos;//id-original,input-id;pos-the priority target's id in array "p",which is 1 at first.Updated by judging if several enemies were killed.
    int HP,hp;
    int MP,mp;
    int atk,datk;
    int def,ddef;
    int tf,tfx,tfy;//Testify? 
    int jn,jnx,jny,jnz;
    bool alive;

    int p[15]={};

    inline int A()
    {
        return max(atk+datk,1);
    }
    inline int D()
    {
        return max(def+ddef,0);
    }

    bool operator < (const Character &c) const
    {
        return jn==c.jn? (id>c.id) : (jn>c.jn); //sort as id-of-skill decrease & id-of-cha decrease, promised that it can be find sequentially.
    }

    void usejn()
    {
        return;
    }
};

struct Player
{
    Character cha[15];
    int cntCha;

    void sortCha()
    {
        sort(cha+1,cha+cntCha+1);
    }
};

Player P[2];

int n,winner;

void init();
void play();
void print(int w);
void playerPlay(int player);
void settle();

bool check();
bool playaRound();

int main()
{
    init();
    play();
    return 0;
}

void play()
{
    int cnt=0;
    for(cnt=1; cnt<=23334; cnt++)
    {
        if(playaRound())
        {
            break;
        }
    }
    if(cnt==23334 || winner==2)
    {
        cout<<"QWQ"<<endl;
    }
    else
    {
        cout<<cnt<<endl;
        print(winner);
    }
    return;
}

void print(int w)
{
    if(w==0)
    {
        cout<<"Alice"<<endl;
    }
    else
    {
        cout<<"Bob"<<endl;
    }
    for(int i=1; i<=P[w].cntCha; i++)
    {
        cout<<P[w].cha[i].hp<<" ";
    }
    cout<<endl;
    return;
}

bool playaRound()
{
    playerPlay(0);
    playerPlay(1);
    settle();
    bool b=check();
    return b;
}

bool check()
{
    bool fA=false,fB=false;
    for(int i=1; i<=n; i++)
    {
        if(P[0].cha[i].alive)
        {
            fA=true; 
        }
        if(P[1].cha[i].alive)
        {
            fB=true;
        }
    }
    if(fA && fB)
    {
        return false;
    }
    else if(!fA && fB)
    {
        winner=1;
    }
    else if(fA && !fB)
    {
        winner=0;
    }
    else
    {
        winner=2;
    }
    return true;
}

void settle()
{

}

void playerPlay(int player)
{
    bool isused=false;
    for(int i=1; i<=P[player].cntCha; i++)
    {
        if(P[player].cha[i].mp == P[player].cha[i].MP)
        {
            P[player].cha[i].usejn();
            isused=true;
            P[player].cha[i].mp=0;
        }
    }
    if(!isused)
    {

    }
}

void init()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>P[0].cha[i].HP>>P[0].cha[i].MP>>P[0].cha[i].atk>>P[0].cha[i].def;
        for(int j=1; j<=n; j++)
        {
            cin>>P[0].cha[i].p[j];
        }
        cin>>P[0].cha[i].tf>>P[0].cha[i].tfx>>P[0].cha[i].tfy;
        cin>>P[0].cha[i].jn>>P[0].cha[i].jnx>>P[0].cha[i].jny>>P[0].cha[i].jnz;
        P[0].cha[i].hp=P[0].cha[i].HP;
        P[0].cha[i].alive=true;
        P[0].cha[i].id=i;
    }
    for(int i=1; i<=n; i++)
    {
        cin>>P[1].cha[i].HP>>P[1].cha[i].MP>>P[1].cha[i].atk>>P[1].cha[i].def;
        for(int j=1; j<=n; j++)
        {
            cin>>P[1].cha[i].p[j];
        }
        cin>>P[1].cha[i].tf>>P[1].cha[i].tfx>>P[1].cha[i].tfy;
        cin>>P[1].cha[i].jn>>P[1].cha[i].jnx>>P[1].cha[i].jny>>P[1].cha[i].jnz;
        P[1].cha[i].hp=P[1].cha[i].HP;
        P[1].cha[i].alive=true;
        P[1].cha[i].id=i;
    }
    P[0].sortCha();
    P[1].sortCha();
    return;
}

//Started at 19:49 10/1/2025.
//Saved at 20:55 10/1/2025.
//Updated (unsubmitted) at 20:58 10/1/2025 at Luogu.