QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767642#5437. Graph CompletingJasonLee#WA 1ms3904kbC++143.8kb2024-11-20 21:33:342024-11-20 21:33:35

Judging History

你现在查看的是最新测评结果

  • [2024-11-20 21:33:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3904kb
  • [2024-11-20 21:33:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using atk_hp = pair<long long, long long>;

double awin, bwin, tie1;


void dfs(bool a_st, const vector<atk_hp>& a, const vector<atk_hp>& b, double p)
{
    if (a_st) {
        int b_size = b.size();
        for (int i = 0; i < b.size(); i++) {
            vector<atk_hp> atemp = a, btemp = b;
            int a_id = 0, b_id = i;
            atemp[a_id].second -= btemp[b_id].first;
            btemp[b_id].second -= atemp[a_id].first;
            vector<atk_hp> outa, outb;
            bool adie = false, bdie = false;
            if (atemp[a_id].second <= 0) {
                adie = true;
            }
            if (btemp[b_id].second <= 0) {
                bdie = true;
            }
            for (int j = 0; j < atemp.size(); j++) {
                if (!(j == a_id && adie == true)) {
                    outa.push_back(atemp[j]);
                }
            }
            for (int j = 0; j < btemp.size(); j++) {
                if (!(j == b_id && bdie == true)) {
                    outb.push_back(btemp[j]);
                }
            }
            bool endit = false;
            if (outa.size() == 0 && outb.size() == 0) {
                tie1 += p;
                endit = true;
            }
            else if (outa.size() == 0) {
                bwin += p;
                endit = true;
            }
            else if (outb.size() == 0) {
                awin += p;
                endit = true;
            }
            if (!endit)
                dfs(!a_st, outa, outb, 1.0 * p / b_size);
        }
    }
    else {
        int a_size = a.size();
        for (int i = 0; i < a.size(); i++) {
            vector<atk_hp> atemp = a, btemp = b;
            int a_id = i, b_id = 0;
            atemp[a_id].second -= btemp[b_id].first;
            btemp[b_id].second -= atemp[a_id].first;
            vector<atk_hp> outa, outb;
            bool adie = false, bdie = false;
            if (atemp[a_id].second <= 0) {
                adie = true;
            }
            if (btemp[b_id].second <= 0) {
                bdie = true;
            }
            for (int j = 0; j < atemp.size(); j++) {
                if (!(j == a_id && adie == true)) {
                    outa.push_back(atemp[j]);
                }
            }
            for (int j = 0; j < btemp.size(); j++) {
                if (!(j == b_id && bdie == true)) {
                    outb.push_back(btemp[j]);
                }
            }
            bool endit = false;
            if (outa.size() == 0 && outb.size() == 0) {
                tie1 += p;
                endit = true;
            }
            else if (outa.size() == 0) {
                bwin += p;
                endit = true;
            }
            else if (outb.size() == 0) {
                awin += p;
                endit = true;
            }
            if (!endit)
                dfs(!a_st, outa, outb, 1.0 * p / a_size);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<atk_hp> a, b;
    for (int i = 0; i < n; i++) {
        long long temp;
        cin >> temp;
        atk_hp t;
        t.first = t.second = temp;
        a.push_back(t);
    }
    for (int j = 0; j < m; j++) {
        long long temp;
        cin >> temp;
        atk_hp t;
        t.first = t.second = temp;
        b.push_back(t);
    }
    if (a.size() > b.size()) {
        awin = 0, bwin = 0, tie1 = 0;
        dfs(true, a, b, 1.0);
    }
    else if (a.size() < b.size()) {
        awin = 0, bwin = 0, tie1 = 0;
        dfs(false, a, b, 1.0);
    }
    else {
        awin = 0, bwin = 0, tie1 = 0;
        dfs(true, a, b, 0.5);
        dfs(false, a, b, 0.5);
    }
    cout << awin << " " << bwin << " " << tie1 << endl;
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3904kb

input:

3 2
1 2
2 3

output:

0 1.5 0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'