QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#771398 | #5444. Tavern Chess | ucup-team3702# | WA | 1ms | 3956kb | C++14 | 1.9kb | 2024-11-22 12:31:30 | 2024-11-22 12:31:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, d, u) for(int i = d; i <= u; ++i)
const int _maxn = 7, _zinf = 1000000001;
int n, m, a[_maxn], b[_maxn], le[_maxn], ri[_maxn];
long long lt[_maxn], rt[_maxn];
struct dats {
double le, ri, bl;
dats() {}
dats(double fi, double se, double th) : le(fi), ri(se), bl(th) {}
};
dats operator+(dats le, dats ri) {
return dats(le . le + ri . le, le . ri + ri . ri, le . bl + ri . bl);
}
dats operator/(dats le, int ri) {
return dats(le . le / ri, le . ri / ri, le . bl / ri);
}
int chek() {
int la = 0, ra = 0;
rep(i, 0, n - 1) {
if(le[i] > 0) {
la = 1;
break;
}
}
rep(i, 0, m - 1) {
if(ri[i] > 0) {
ra = 1;
break;
}
}
return la << 1 | ra;
}
dats dfs1(bool at) {
switch(chek()) {
case 0 : return dats(0, 0, 1);
case 1 : return dats(0, 1, 0);
case 2 : return dats(1, 0, 0);
}
int mi = _zinf, po, cn = 0;
dats re(0, 0, 0);
if(at) {
rep(i, 0, m - 1) {
if(ri[i] > 0 && mi > rt[i]) {
mi = rt[i], po = i;
}
}
rep(i, 0, n - 1) {
if(le[i] > 0) {
le[i] -= b[po], ri[po] -= a[i], rt[po] += a[i];
re = re + dfs1(0), ++cn;
le[i] += b[po], ri[po] += a[i], rt[po] -= a[i];
}
}
} else {
rep(i, 0, n - 1) {
if(le[i] > 0 && mi > lt[i]) {
mi = lt[i], po = i;
}
}
rep(i, 0, m - 1) {
if(ri[i] > 0) {
ri[i] -= a[po], le[po] -= b[i], lt[po] += b[i];
re = re + dfs1(1), ++cn;
ri[i] += a[po], le[po] += b[i], lt[po] -= b[i];
}
}
}
return re / cn;
}
int main() {
cin >> n >> m;
rep(i, 0, n - 1) {
cin >> a[i], le[i] = a[i];
}
rep(i, 0, m - 1) {
cin >> b[i], ri[i] = b[i];
}
dats rans;
if(n > m) {
rans = dfs1(0);
} else if(n < m) {
rans = dfs1(1);
} else {
rans = (dfs1(0) + dfs1(1)) / 2;
}
printf("%.15lf\n%.15lf\n%.15lf\n", rans . le, rans . ri, rans . bl);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
input:
2 3 2 5 3 4 1
output:
0.125000000000000 0.750000000000000 0.125000000000000
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 3900kb
input:
6 6 1 1 4 5 1 4 1 1 4 5 1 4
output:
0.241867283950617 0.241867283950617 0.516265432098766
result:
ok 3 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3896kb
input:
7 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
0.000000000000000 0.000000000000000 1.000000000000000
result:
ok 3 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1 7 7 1 1 1 1 1 1 1
output:
0.000000000000000 0.000000000000000 1.000000000000000
result:
ok 3 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
2 3 736618938 652769331 328875880 97571721 44608905
output:
1.000000000000000 0.000000000000000 0.000000000000000
result:
ok 3 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
5 4 53585130 731696211 668322278 611205195 158818781 569587984 776042583 745745433 330119007
output:
0.066840277777778 0.664351851851852 0.268807870370370
result:
ok 3 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
7 2 578505806 551611151 92903265 403642038 542119417 57334031 307573613 897644535 168524310
output:
1.000000000000000 0.000000000000000 0.000000000000000
result:
ok 3 numbers
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3832kb
input:
5 6 113196606 64768263 772808463 787707989 500151952 481840741 676847825 4641268 431386165 847736311 169677832
output:
0.136268775720165 0.522602623456790 0.341128600823045
result:
wrong answer 1st numbers differ - expected: '0.1363232', found: '0.1362688', error = '0.0000544'