QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275098#7903. Computational Intelligenceucup-team1209WA 1270ms4036kbC++201.6kb2023-12-04 13:23:302023-12-04 13:23:30

Judging History

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

  • [2023-12-04 13:23:30]
  • 评测
  • 测评结果:WA
  • 用时:1270ms
  • 内存:4036kb
  • [2023-12-04 13:23:30]
  • 提交

answer

#include<random>
#include<iostream>
#include<complex>
#include<cmath>
#include<cstdio>
using std::cin;
using std::cout;
using db = double;
using cp = std::complex<db>;
const int N = 699;
std::pair<cp, cp> get() {
	int x1, y1;
	int x2, y2;
	cin >> x1 >> y1;
	cin >> x2 >> y2;
	return {cp(x1, y1), cp(x2, y2)};
}


cp A, B, C;
db a, a4, a2;
db sqa;
db cbrta;

db eval(db t) {
	cp X = A * t + C;
	db b = B.real() * X.real() + B.imag() * X.imag();
	db c = std::norm(X);
	db s = a + b + c;
	db val1 = std::sqrt(std::max(s, 0.));
	db val0 = std::sqrt(c);
	db ans = b / a4 * (val1 - val0);
	ans += val1 / 2;

	db xx = (a4 * c - b * b) / cbrta;
	if(xx > 1e-9)  {
		db w = std::fabs((a2 + b + sqa * val1) / (b + sqa * val0));
		if(w > 1e-9)
			ans += xx * log(w); 
	}
	return ans;
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	int T;
	cin >> T;
	for(int i = 0;i < T;++i) {
		auto [a0, b0] = get();
		auto [a1, b1] = get();
		if(std::abs(a0 - b0) < std::abs(a1 - b1)) {
			std::swap(a0, a1);
			std::swap(b0, b1);
		}
		A = (b0 - a0);
		B = -(b1 - a1);
		C = a0 - a1;
		a = std::norm(B);
		a4 = a * 4;
		a2 = a * 2;
		sqa = std::sqrt(std::norm(B)) * 2;
		B *= 2;
		cbrta = std::sqrt(a * a * a) * 8;

		int cnt = 0;
		db sum = (eval(0) + eval(1)) * 17
			+ 59 * (eval(1. / N) + eval(1 - 1. / N))
			+ 43 * (eval(2. / N) + eval(1 - 2. / N))
			+ 49 * (eval(3. / N) + eval(1 - 3. / N));
		cnt += (17 + 59 + 43 + 49) * 2;
		cnt += (N - 7) * 48;
		for(int i = 4;i <= N - 4;++i) {
			sum += eval((db)i / N) * 48;
		}
		sum /= cnt;
		printf("%.11lf\n", sum);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0 0 1 0
0 0 1 0
0 0 1 0
0 0 0 1
0 0 1 0
0 1 1 1

output:

0.33333333333
0.76519571654
1.07663573290

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

3
0 1 0 0
0 -1 0 2
0 0 1 0
2 0 -1 0
-1000 0 0 999
0 -998 999 0

output:

0.77777777778
0.77777777778
1521.07040502462

result:

ok 3 numbers

Test #3:

score: -100
Wrong Answer
time: 1270ms
memory: 4036kb

input:

100000
-4 -10 -8 -8
5 5 -10 -8
-10 10 -1 -3
-3 5 -1 -3
8 -7 8 -10
0 -3 0 10
6 -1 0 2
0 -3 3 1
-6 -5 5 3
3 5 -4 -8
1 9 1 -1
2 -1 -6 0
1 -2 -7 -9
-1 -2 -4 5
6 -10 7 1
0 -6 -8 -8
-10 9 2 3
-7 -10 4 -9
8 4 4 9
-9 3 0 4
5 -2 9 8
-9 -5 7 8
-1 1 0 1
-4 1 -8 1
3 3 10 3
3 0 -6 -2
-3 -3 -3 3
-2 7 -10 -7
9 2 6...

output:

9.02826761735
5.74413144919
14.59427870289
2.95217824572
4.99350269429
6.05871725566
7.45940870025
11.22802890792
16.32570784750
11.07224515719
9.50455745116
5.50000000000
9.04004998583
5.32634791089
3.03593437129
5.80880418594
17.36371978952
9.99519451924
6.99330262288
6.55043322949
9.16357872496
8...

result:

wrong answer 143rd numbers differ - expected: '10.2888720', found: '10.2888720', error = '0.0000000'