QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#771408#5444. Tavern Chessucup-team3702#WA 1ms3912kbC++141.9kb2024-11-22 12:36:252024-11-22 12:36:35

Judging History

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

  • [2024-11-22 12:36:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3912kb
  • [2024-11-22 12:36:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i, d, u) for(int i = d; i <= u; ++i)
const int _maxn = 7;
const long long _zinf = 1000000000000000001;
int n, m;
long long a[_maxn], b[_maxn], le[_maxn], ri[_maxn], 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);
	}
	long long mi = _zinf;
	int 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, 1 - rans . le - rans . ri);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3880kb

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: 3912kb

input:

6 6
1 1 4 5 1 4
1 1 4 5 1 4

output:

0.241867283950617
0.241867283950617
0.516265432098765

result:

ok 3 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 3724kb

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: 3848kb

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: 3796kb

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: 3776kb

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: 3844kb

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: 1ms
memory: 3796kb

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'