QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#177191 | #5438. Half Mixed | ucup-team963# | WA | 1ms | 3744kb | C++14 | 2.4kb | 2023-09-12 17:27:47 | 2023-09-12 17:27:48 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
pair<double, double> dfs(vector<array<int,4>> a, vector<array<int,4>> b, int flg) {
if(a.size() == 0 && b.size() == 0) return {0, 1};
if(a.size() == 0) return {0, 0};
if(b.size() == 0) return {1, 0};
if(flg == 1) {
pair<double,double> res;
sort(a.begin(), a.end());
int bs = b.size();
double rate = 1.0 / bs;
for(int i = 0; i < bs; ++ i) {
auto na = a, nb = b;
auto pa = na.begin(), pb = nb.begin() + i;
(*pa)[2] -= (*pb)[3];
(*pb)[2] -= (*pa)[3];
if((*pa)[2] <= 0) na.erase(pa);
else ++ (*pa)[0];
if((*pb)[2] <= 0) nb.erase(pb);
auto ret = dfs(na, nb, 2);
res.fi += ret.fi * rate;
res.se += ret.se * rate;
}
return res;
} else {
pair<double,double> res;
sort(b.begin(), b.end());
int as = a.size();
double rate = 1.0 / as;
for(int i = 0; i < as; ++ i) {
auto na = a, nb = b;
auto pa = na.begin() + i, pb = nb.begin();
(*pa)[2] -= (*pb)[3];
(*pb)[2] -= (*pa)[3];
if((*pa)[2] <= 0) na.erase(pa);
if((*pb)[2] <= 0) nb.erase(pb);
else ++ (*pb)[0];
auto ret = dfs(na, nb, 1);
res.fi += ret.fi * rate;
res.se += ret.se * rate;
}
return res;
}
}
signed main() {
if(fopen("yl.in", "r")) {
freopen("yl.in", "r", stdin);
freopen("yl.out", "w", stdout);
}
int n, m;
cin >> n >> m;
vector<array<int,4>> a(n), b(m);
rep(i,0,n - 1) {
a[i][0] = 0; a[i][1] = i;
cin >> a[i][2]; a[i][3] = a[i][2];
}
rep(i,0,m - 1) {
b[i][0] = 0; b[i][1] = i;
cin >> b[i][2]; b[i][3] = b[i][2];
}
pair<double,double> it,i2;
if(a.size() == b.size()) {
it = dfs(a, b, 1);
i2 = dfs(a, b, 2);
it = make_pair(0.5 * (it.fi + i2.fi), 0.5 * (it.se + i2.se));
} else if(a.size() < b.size()) it = dfs(a, b, 2);
else it = dfs(a, b, 1);
cout.setf(ios::fixed);
cout.precision(15);
cout << it.fi << '\n' << 1 - it.fi - it.se << '\n' << it.se << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3744kb
input:
2 2 3 1 1
output:
1.000000000000000 0.000000000000000 0.000000000000000
result:
wrong answer Token "1.000000000000000" doesn't correspond to pattern "Yes|No" (test case 1)