16分求调
查看原帖
16分求调
742017
zhangxiao666楼主2025/7/25 16:20
#include <bits/stdc++.h>
using namespace std;

const int N = 15;
const int Round = 23333;

int n, cnta, cntb;
int rd;

struct Person
{
    int HP, hp, MP, mp, atk, de_atk, def, de_def;
    int A, D;
    int bel, live = 1; 
    int tf, tf_x, tf_y;
    int jn, jn_x, jn_y, jn_z;
    int p[N];

    void Addhp(int x) {if (!live) return; hp += x; if (hp < 0) hp = 0; if (hp > HP) hp = HP;}
    void Addmp(int x) {if (!live) return; mp += x; if (mp < 0) mp = 0; if (mp > MP) mp = MP;}
    void Get() {if (!live) return; A = max(atk + de_atk, 1), D = max(def + de_def, 0);}
    void Live() {if (!live) return; if (hp <= 0) {live = 0, hp = 0; if (bel == 0) cnta--; else cntb--;}}

} a[N][2];
int de_atk[500000][2], de_def[500000][2], de_mp[500000][2];
int now_atk[500000][2], now_def[500000][2];
int berd, ovrd, which;

void Check() {
    if (cnta == 0) {
        cout << rd << "\n";
        cout << "Bob\n";
        for (int i = 1; i <= n; i++) cout << a[i][1].hp << " ";
        exit(0);
    }
    if (cntb == 0) {
        cout << rd << "\n";
        cout << "Alice\n";
        for (int i = 1; i <= n; i++) cout << a[i][0].hp << " ";
        exit(0);        
    }
}

void Read() {
    cin >> n; cnta = cntb = n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i][0].HP >> a[i][0].MP >> a[i][0].atk >> a[i][0].def;
        for (int j = 1; j <= n; j++) cin >> a[i][0].p[j];
        cin >> a[i][0].tf >> a[i][0].tf_x >> a[i][0].tf_y;
        cin >> a[i][0].jn >> a[i][0].jn_x >> a[i][0].jn_y >> a[i][0].jn_z;
        a[i][0].Get(), a[i][0].hp = a[i][0].HP;
        a[i][0].bel = 0;
    }
    for (int i = 1; i <= n; i++) {
        cin >> a[i][1].HP >> a[i][1].MP >> a[i][1].atk >> a[i][1].def;
        for (int j = 1; j <= n; j++) cin >> a[i][1].p[j];
        cin >> a[i][1].tf >> a[i][1].tf_x >> a[i][1].tf_y;
        cin >> a[i][1].jn >> a[i][1].jn_x >> a[i][1].jn_y >> a[i][1].jn_z;
        a[i][1].Get(), a[i][1].hp = a[i][1].HP;
        a[i][1].bel = 1;
    }
}

void Buff() {
    for (int op = 0; op <= 1; op++) {
        now_atk[rd][op] = de_atk[rd][op], now_def[rd][op] = de_def[rd][op];
        // cout << now_atk[rd][op] << " " << now_def[rd][op] << " ";
     // cout << "\n";        
    }

    for (int i = 1; i <= n; i++) {
        for (int op = 0; op <= 1; op++) {
            if (!a[i][op].live) continue;
            a[i][op].de_atk += now_atk[rd][op];
            a[i][op].de_def += now_def[rd][op];
            a[i][op].Get();
        }
    }
}

void DeBuff() {
    for (int i = 1; i <= n; i++) {
        for (int op = 0; op <= 1; op++) {
            if (!a[i][op].live) continue;
            a[i][op].de_atk -= now_atk[rd][op];
            a[i][op].de_def -= now_def[rd][op];
            a[i][op].Get();
        }
    }
}

void Kill(int x, int op, int d, int zs) {
    if (!a[x][op].live) return;
    if (a[x][op].tf == 1)   
        a[x][op].Addhp(-(max(d - a[x][op].D, 0) + zs - zs / 2));
    else
        a[x][op].Addhp(-(max(d - a[x][op].D, 0) + zs));
    a[x][op].Live(); Check();  
    if (a[x][op].live) a[x][op].Addmp(1);
}

int Killnum(int x, int op, int d, int zs ) {
    if (a[x][op].tf == 1)   
        return (max(d - a[x][op].D, 0) + zs - zs / 2);
    else
        return (max(d - a[x][op].D, 0) + zs);
}

int Goal(int x, int op) {
    if (x == 0) return 0;
    for (int i = 1; i <= n; i++) {
        if (a[a[x][op].p[i]][op ^ 1].live == 1) return a[x][op].p[i];
    }
    return 0;
}

void Skill(int x, int op) {
    int goal = Goal(x, op), en = 0;
    // if (op == 0) cout << "Alice";
    // else cout << "Bob";
    // cout << x <<  "使用技能" << a[x][op].jn << "\n";
    if (a[x][op].jn == 0) return;
    if (a[x][op].jn == 1) {
        for (int i = 1; i <= n; i++) {
            if (!a[i][op ^ 1].live) continue;
            Kill(i, op ^ 1 , a[x][op].jn_x, 0);
            Check();
            if (!a[i][op ^ 1].live) continue;
            en = a[i][op ^ 1].mp;
            // a[i][op ^ 1].mp = max(0, en - (en / 10));
            a[i][op ^ 1].Addmp(-(en / 10));
        }
    }
    if (a[x][op].jn == 2) {
        for (int i = 1; i <= n; i++) 
            Kill(i, op ^ 1, 0, a[x][op].A);
    }
    if (a[x][op].jn == 3) {
        a[x][op].Get();
        for (int i = 1; i <= n; i++) 
            Kill(i, op ^ 1, min(a[i][op ^ 1].HP / 10, a[x][op].A * a[x][op].jn_x), 0);
    }
    if (a[x][op].jn == 4) {
        for (int i = rd; i <= min(rd + a[x][op].jn_x - 1, Round); i++) 
            de_mp[i][op] += a[x][op].jn_y;
    }
    if (a[x][op].jn == 5) {
        a[goal][op ^ 1].de_def -= a[x][op].jn_x;
        a[goal][op ^ 1].Get();
        Kill(goal, op ^ 1, 0, a[x][op].A);
    }
    if (a[x][op].jn == 6) {
        Kill(goal, op ^ 1, 0, a[x][op].A);
        for (int i = rd; i <= min(rd + a[x][op].jn_x - 1, Round); i++)
            de_def[i][op ^ 1] -= a[x][op].jn_y;
    }
    if (a[x][op].jn == 7) {
        int id = 0;
        for (int i = 1; i <= n; i++) 
            if (a[i][op].live &&  (id == 0 || a[i][op].hp < a[id][op].hp)) id = i;
        if (id) a[id][op].Addhp(a[x][op].jn_z);
        for (int i = rd; i <= min(rd + a[x][op].jn_x - 1, Round); i++) 
            de_atk[i][op] += a[x][op].jn_y;
    }
    if (a[x][op].jn == 8)  {
        for (int i = 1; i <= n; i++) 
            Kill(i, op ^ 1, a[x][op].A, 0);
        for (int i = rd; i <= min(rd + a[x][op].jn_x - 1, Round); i++)
            de_def[i][op ^ 1] -= a[x][op].jn_y;
    }
    if (a[x][op].jn == 9) {
        for (int i = 1; i <= n; i++) 
            a[i][op].Addhp(a[x][op].jn_z);
        for (int i = rd; i <= min(rd + a[x][op].jn_x - 1, Round); i++)
            de_def[i][op] += a[x][op].jn_y;
    }
    if (a[x][op].jn == 10) {
        for (int i = 1; i <= n; i++) {
            if (!a[i][op].live) continue;
            a[i][op].atk *= 2; a[i][op].def *= 2;
            a[i][op].hp = max(a[i][op].hp, a[i][op].HP / 2);
            a[i][op].mp = max(a[i][op].mp, a[i][op].MP / 2);
            a[i][op].Get();
        }
        for (int i = 1; i <= n; i++) 
            for (int o = 0; o <= 1; o++)
                if (a[i][o].jn == 10) a[i][o].jn = 0;
        berd = rd, ovrd = rd + a[x][op].jn_x - 1;
        // cout << ovrd << "\n";
        for (int i = berd; i <= min(ovrd, Round); i++)
            de_mp[i][op] ++;
        which = op;
    }
}

void Work(int op) {
    for (int i = 1; i <= n; i++) a[i][0].Get(), a[i][1].Get();
    //攻击
    bool f = 0;
    int id = 0;
    for (int i = n; i >= 1; i--) {
        if (a[i][op].live && a[i][op].mp >= a[i][op].MP) {
            if (id == 0) id = i;
            else if (a[i][op].jn > a[id][op].jn) id = i;
            else if (a[i][op].jn == a[id][op].jn && i > id) id = i;
        }
    } 
    if (id) {
        a[id][op].mp = 0;
        Skill(id, op);
        if (a[id][op].tf == 5)
            a[id][op].Addmp(a[id][op].tf_y);
        a[id][op].Addmp(1);
        DeBuff(); Buff();
    }           
 
    else {
        // if (op == 0) cout << "Alice";
        // else cout << "Bob";
        id = 0; int now = 0;
        for (int i = 1; i <= n; i++) {
            if (!a[i][op].live) continue;
            int p = Goal(i, op), gl = Goal(id, op);
            int num = 0;
            if (a[i][op].tf == 2) num = Killnum(p, op ^ 1, a[i][op].A, a[i][op].tf_x);
            else if (a[i][op].tf == 4) num = Killnum(p, op ^ 1, 0, a[i][op].A);
            else num = Killnum(p, op ^ 1, a[i][op].A, 0);
            if (id == 0) id = i, now = num;
            else if (a[p][op ^ 1].hp > a[gl][op ^ 1].hp) id = i, now = num;
            else if (a[p][op ^ 1].hp == a[gl][op ^ 1].hp) {
                if (num >= now) id = i, now = num;
            }
        }
        if (id == 0) Check();
        int p = Goal(id, op);
        // cout << id << "对" << p << "普攻,造成" << now << "点伤害\n";
        if (a[id][op].tf == 2) Kill(p, op ^ 1, a[id][op].A, a[id][op].tf_x);
        else if (a[id][op].tf == 4) Kill(p, op ^ 1, 0, a[id][op].A);
        else Kill(p, op ^ 1, a[id][op].A, 0); 
        a[id][op].Addmp(1);
        if (a[id][op].tf == 5) a[id][op].Addhp(a[id][op].tf_x);    
    }
    
    //回复
    for (int i = 1; i <= n; i++) {
        if (a[i][op].live) {
            a[i][op].Addmp(1);
            a[i][op].Addmp(de_mp[rd][op]);
            if (a[i][op].tf == 3) 
                a[i][op].Addhp(a[i][op].tf_x), a[i][op].Addmp(a[i][op].tf_y);
        }
    }
    // cout << rd << " " << ovrd << "\n";
}


int main() {
    // std::ios::sync_with_stdio(false);
    // cin.tie(0), cout.tie(0);
    Read();
    while (rd < Round) {
        // cout << "##" << ovrd << "##\n";
        rd++; 
        // cout << rd << "\n";
        Buff();
        Work(0), Check(); 
        Work(1), Check();
        DeBuff();
        if (rd == ovrd) {
            if (which == 0) cnta = 0;
            else cntb = 0;
        }    
        Check();
        // cout << "目前局势:\n";
        // cout << "Alice:剩余血量 ";
        // for (int i = 1; i <= n; i++) cout << a[i][0].hp << "(" << a[i][0].mp << ")" << " ";
        // cout << "\nBob:剩余血量 ";
        // for (int i = 1; i <= n; i++) cout << a[i][1].hp << "(" << a[i][1].mp << ")" << " ";
        // cout << "\n";
    }
    Check();
    cout << "QwQ orz chu ti ren";
    return 0;
}
2025/7/25 16:20
加载中...