QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#771700#5444. Tavern Chessucup-team3702WA 1ms3932kbC++141.7kb2024-11-22 15:07:232024-11-22 15:07:25

Judging History

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

  • [2024-11-22 15:07:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3932kb
  • [2024-11-22 15:07:23]
  • 提交

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];
double lans, rans;
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;
}
void dfs1(bool at, double da) {
	switch(chek()) {
		case 0 : return;
		case 1 : rans += da;return;
		case 2 : lans += da;return;
	}
	long long mi = _zinf;
	int po, cn = 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) {
				++cn;
			}
		}
		rep(i, 0, n - 1) {
			if(le[i] > 0) {
				le[i] -= b[po], ri[po] -= a[i], rt[po] += a[i];
				dfs1(0, da / 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) {
				++cn;
			}
		}
		rep(i, 0, m - 1) {
			if(ri[i] > 0) {
				ri[i] -= a[po], le[po] -= b[i], lt[po] += b[i];
				dfs1(1, da / cn);
				ri[i] += a[po], le[po] += b[i], lt[po] -= b[i];
			}
		}
	}
}
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];
	}
	if(n > m) {
		dfs1(0, 1);
	} else if(n < m) {
		dfs1(1, 1);
	} else {
		dfs1(0, 0.5), dfs1(1, 0.5);
	}
	printf("%.15lf\n%.15lf\n%.15lf\n", lans, rans, 1 - lans - rans);
	return 0;
}

详细

Test #1:

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

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

input:

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

output:

0.241867283950625
0.241867283950620
0.516265432098755

result:

ok 3 numbers

Test #3:

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

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

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

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

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

input:

7 2
578505806 551611151 92903265 403642038 542119417 57334031 307573613
897644535 168524310

output:

0.999999999999999
0.000000000000000
0.000000000000001

result:

ok 3 numbers

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 3884kb

input:

5 6
113196606 64768263 772808463 787707989 500151952
481840741 676847825 4641268 431386165 847736311 169677832

output:

0.136268775720165
0.522602623456781
0.341128600823054

result:

wrong answer 1st numbers differ - expected: '0.1363232', found: '0.1362688', error = '0.0000544'