QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#265128#7753. Energy Distributionucup-team022#WA 138ms3964kbC++171.1kb2023-11-25 16:53:192023-11-25 16:53:19

Judging History

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

  • [2024-10-31 10:22:30]
  • hack成功,自动添加数据
  • (/hack/1089)
  • [2023-11-25 16:53:19]
  • 评测
  • 测评结果:WA
  • 用时:138ms
  • 内存:3964kb
  • [2023-11-25 16:53:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int, int> pr;
int n;
db w[15][15], a[15], sw[15];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) cin >> w[i][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) sw[i] += w[i][j];
	for (int i = 1; i <= n; i++) a[i] = 1.0 / n;
	for (int kk = 1; kk <= 150000; kk++) {
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				db sum = a[i] + a[j];
				db U = 0;
				db V = 0;
				for (int k = 1; k <= n; k++) {
					if (k != j) U += a[k] * w[i][k];
					if (k != i) V += a[k] * w[j][k];
				}
				db A = -w[i][j];
				db B = w[i][j] * sum + U - V;
				if (!w[i][j]) {
					if (B > 0) a[i] = sum, a[j] = 0;
					else a[j] = sum, a[i] = 0;
					continue;
				}
				db best = -B / A / 2;
				best = min(sum, max(best, (db)0));
				a[i] = best, a[j] = sum - best;
			}
		}
	}
	db ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++) ans += w[i][j] * a[i] * a[j];
	printf("%.10Lf\n", ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3816kb

input:

2
0 1
1 0

output:

0.2500000000

result:

ok found '0.2500000', expected '0.2500000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 8ms
memory: 3804kb

input:

3
0 2 1
2 0 2
1 2 0

output:

0.5714285714

result:

ok found '0.5714286', expected '0.5714290', error '0.0000004'

Test #3:

score: 0
Accepted
time: 8ms
memory: 3920kb

input:

3
0 1 2
1 0 1
2 1 0

output:

0.5000000000

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 15ms
memory: 3920kb

input:

4
0 3 1 0
3 0 1 0
1 1 0 2
0 0 2 0

output:

0.7500000000

result:

ok found '0.7500000', expected '0.7500000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 28ms
memory: 3812kb

input:

5
0 0 0 4 4
0 0 2 0 4
0 2 0 2 0
4 0 2 0 0
4 4 0 0 0

output:

1.0000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 41ms
memory: 3932kb

input:

6
0 9 5 5 10 6
9 0 0 0 0 1
5 0 0 0 3 0
5 0 0 0 10 5
10 0 3 10 0 0
6 1 0 5 0 0

output:

2.8571428571

result:

ok found '2.8571429', expected '2.8571430', error '0.0000001'

Test #7:

score: 0
Accepted
time: 71ms
memory: 3936kb

input:

7
0 0 0 0 50 10 45
0 0 0 0 0 3 1
0 0 0 0 0 4 16
0 0 0 0 44 0 0
50 0 0 44 0 37 6
10 3 4 0 37 0 2
45 1 16 0 6 2 0

output:

12.5115848007

result:

ok found '12.5115848', expected '12.5115850', error '0.0000000'

Test #8:

score: 0
Accepted
time: 104ms
memory: 3964kb

input:

8
0 0 56 0 0 58 16 0
0 0 37 20 0 82 0 0
56 37 0 0 98 0 83 0
0 20 0 0 0 0 100 0
0 0 98 0 0 62 29 0
58 82 0 0 62 0 43 0
16 0 83 100 29 43 0 4
0 0 0 0 0 0 4 0

output:

25.0091178965

result:

ok found '25.0091179', expected '25.0091180', error '0.0000000'

Test #9:

score: -100
Wrong Answer
time: 138ms
memory: 3812kb

input:

9
0 0 0 135 0 0 0 448 476
0 0 0 0 0 0 208 17 0
0 0 0 467 1 0 0 0 134
135 0 467 0 0 0 92 369 207
0 0 1 0 0 176 0 235 0
0 0 0 0 176 0 65 363 413
0 208 0 92 0 65 0 0 0
448 17 0 369 235 363 0 0 0
476 0 134 207 0 413 0 0 0

output:

113.7908670025

result:

wrong answer 1st numbers differ - expected: '119.0000000', found: '113.7908670', error = '0.0437742'