QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#755986#5444. Tavern Chessenar#WA 0ms3768kbC++202.7kb2024-11-16 18:38:092024-11-16 18:38:09

Judging History

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

  • [2024-11-16 18:38:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3768kb
  • [2024-11-16 18:38:09]
  • 提交

answer

#include <bits/stdc++.h>
using i64 = long long;

void solve() {
    int n, m;
    std::cin >> n >> m;
    std::vector<int> a(n);
    std::vector<int> b(m);
    for(auto &val : a) {
        std::cin >> val;
    }
    for(auto &val : b) {
        std::cin >> val;
    }
    auto func = [](std::vector<int> a, std::vector<int> b) ->std::array<int, 3> {
        std::vector atk = {a, b};
        std::vector h = {a, b};
        std::array<int, 2> num = {(int)a.size(), (int)b.size()};
        std::vector times = {std::vector<int>(a.size(), 0), std::vector<int>(b.size(), 0)};
        std::array<int, 3> res{};
        auto find = [&](auto self, int id) ->void {
            int num1 = 0, num2 = 0;
            for(int i = 0; i < num[id]; ++i) {
                num1 += (h[id][i] <= 0);
            }
            for(int i = 0; i < num[id ^ 1]; ++i) {
                num2 += (h[id ^ 1][i] <= 0);
            }
            if(num1 == num[id] || num2 == num[id ^ 1]) {
                if(num1 == num[id] && num2 == num[id ^ 1]) {
                    res[2]++;
                } else if(num1 == num[id] && num2 != num[id ^ 1]) {
                    res[id ^ 1]++;
                } else if(num1 != num[id] && num2 == num[id ^ 1]) {
                    res[id]++;
                }
                return;
            }
            int mn = INT_MAX;
            int idx = num[id];
            for(int i = 0; i < num[id]; ++i) {
                if(h[id][i] <= 0) continue;
                if(times[id][i] < mn) {
                    idx = i;
                    mn = times[id][i];
                }
            }
            for(int i = 0; i < num[id ^ 1]; ++i) {
                if(h[id ^ 1][i] <= 0) continue;
                h[id][idx] -= atk[id ^ 1][i];
                h[id ^ 1][i] -= atk[id][idx];
                times[id][idx]++;
                self(self, id ^ 1);
                times[id][idx]--;
                h[id ^ 1][i] += atk[id][idx];
                h[id][idx] += atk[id ^ 1][i];
            }
        };
        find(find, 0);
        return res;
    };
    int x = 0, y = 0, z = 0;
    if(n >= m) {
        std::array<int, 3> res = func(a, b);
        x += res[1], y += res[0], z += res[2];
    }
    if(n <= m) {
        std::array<int, 3> res = func(b, a);
        x += res[1], y += res[0], z += res[2];
    }
    int sum = x + y + z;
    std::cout << std::fixed << std::setprecision(12);
    std::cout << double(x) / sum << '\n';
    std::cout << double(y) / sum << '\n'; 
    std::cout << double(z) / sum << '\n'; 
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    // std::cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3768kb

input:

2 3
2 5
3 4 1

output:

0.166666666667
0.666666666667
0.166666666667

result:

wrong answer 1st numbers differ - expected: '0.1250000', found: '0.1666667', error = '0.0416667'