QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#756061 | #5444. Tavern Chess | enar | WA | 1ms | 3808kb | C++20 | 2.9kb | 2024-11-16 18:53:48 | 2024-11-16 18:53:50 |
Judging History
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<double, 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<double, 3> res{};
auto find = [&](auto self, int id, double p) ->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] += p;
} else if(num1 == num[id] && num2 != num[id ^ 1]) {
res[id ^ 1] += p;
} else if(num1 != num[id] && num2 == num[id ^ 1]) {
res[id] += p;
}
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];
}
}
int count = 0;
for(int i = 0; i < num[id ^ 1]; ++i) {
if(h[id ^ 1][i] <= 0) continue;
count++;
}
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, p / count);
times[id][idx]--;
h[id ^ 1][i] += atk[id][idx];
h[id][idx] += atk[id ^ 1][i];
}
};
find(find, 0, 1);
return res;
};
double x = 0, y = 0, z = 0;
if(n >= m) {
std::array<double, 3> res = func(a, b);
x += res[1], y += res[0], z += res[2];
}
if(n <= m) {
std::array<double, 3> res = func(b, a);
x += res[1], y += res[0], z += res[2];
}
if(n == m) {
x /= 2, y /= 2, z /= 2;
}
std::cout << std::fixed << std::setprecision(12);
std::cout << x << '\n';
std::cout << y << '\n';
std::cout << z << '\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: 100
Accepted
time: 0ms
memory: 3808kb
input:
2 3 2 5 3 4 1
output:
0.125000000000 0.750000000000 0.125000000000
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3800kb
input:
6 6 1 1 4 5 1 4 1 1 4 5 1 4
output:
0.238942901235 0.244791666667 0.516265432099
result:
wrong answer 1st numbers differ - expected: '0.2418673', found: '0.2389429', error = '0.0029244'