QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#322315#6763. Triangle PendantPetroTarnavskyi#WA 3ms4340kbC++202.6kb2024-02-06 20:14:112024-02-06 20:14:11

Judging History

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

  • [2024-02-06 20:14:11]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4340kb
  • [2024-02-06 20:14:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); i--)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const db PI = acos(-1.); 

//watching c
db kut(db a, db b, db c)
{
	db val = (a * a + b * b - c * c) / (2 * a * b);
	return acos(val);
}
db len(db a, db b, db kut)
{
	return sqrt(a * a + b * b - 2 * a * b * cos(kut));
}
//to C
db med(db a, db b, db c)
{
	return sqrt(2 * a * a + 2 * b * b - c * c) / 2;	
}
pair<bool, vector<db>> check1(db x, db y, db z, db a, db b, db c)
{
	db m = med(b, c, a);
	
	bool ok = 1;
	vector<db> ans(3);
	ans[0] = x;
	FOR(it, 1, 3)
	{
		db alphaC = kut(m, a / 2, c);
		ok &= (len(x + m, a / 2, alphaC) < y);
		
		ans[it] = x + m + a/2 * sin(alphaC - PI/2);
		
		swap(b, c);
		swap(z, y);
	}
	
	return MP(ok, ans);
}
pair<bool, vector<db>> check2(db x, db y, db z, db a, db b, db c)
{
	db m1 = med(x, y, c);
	db m2 = med(a, b, c);
	
	vector<db> ans(3);
	
	if(m1 + m2 < z)
	{		
		ans[0] = m1 + sin(kut(m1, c / 2, x) - PI/2) * c/2;
		ans[1] = m1 + sin(kut(m1, c / 2, y) - PI/2) * c/2;
		ans[2] = m1 + m2;
	}
	else
		return MP(0, ans);
	
	return MP(m1 + m2 < z, ans);
}
db r[3], a[3];
vector<db> check3()
{
	db m1 = med(r[1], r[2], a[0]);
	db m2 = med(a[1], a[2], a[0]);
	
	db alpha = kut(m1, m2, r[0]);
	db h = len(m1, m2 / 3, alpha);
	
		
	vector<db> ans(3);
	FOR(i, 0, 3)
	{
		db m = med(a[(i + 1) % 3], a[(i + 2) % 3], a[i]);
		alpha = kut(h, 2 * m / 3, r[i]);
		ans[i] = h + sin(alpha - PI / 2) * (2 * m / 3);
	}

	return ans;
}





void print(vector<db> H, int t)
{
	//H[0] = ans[t]
	FOR(i, 0, 3)
	{
		//ans[i] = H[i - t]
		if(i)
			cout << " ";
		cout << -H[(i + 3 - t) % 3];
	}
	cout << "\n";
}

void solve()
{
	FOR(i, 0, 3)
		cin >> r[i];
	FOR(i, 0, 3)
		cin >> a[i];
	
	FOR(i, 0, 3)
	{
		auto res = check1(r[i], r[(i + 1) % 3], r[(i + 2) % 3], a[i], a[(i + 1) % 3], a[(i + 2)%3]);
		if(res.F)
		{
			print(res.S, i);
			return;
		}
	}
	FOR(i, 0, 3)
	{
		auto res = check2(r[i], r[(i + 1) % 3], r[(i + 2) % 3], a[i], a[(i + 1) % 3], a[(i + 2)%3]);
		if(res.F)
		{
			print(res.S, i);
			return;
		}
	}
	auto res = check3();
	print(res, 0);
}




int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	cout << fixed << setprecision(15);
	
	int t;
	cin >> t;
	while(t--)
		solve();
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
1 1 1 1 1 1
2 3 3 1 1 1

output:

-0.816496580927726 -0.816496580927726 -0.816496580927726
-2.000000000000000 -2.866025403784438 -2.866025403784438

result:

ok 6 numbers

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 4340kb

input:

1000
21 2 14 12 13 4
29 19 13 15 10 17
29 24 15 29 24 23
29 17 30 18 9 25
27 24 30 16 4 15
28 13 17 12 21 16
16 22 10 22 15 8
15 23 24 23 27 13
26 3 27 15 16 17
5 8 20 17 6 12
24 14 13 15 19 13
27 22 18 18 23 30
22 18 14 11 29 28
7 13 22 22 17 11
19 9 16 22 20 17
21 14 20 6 29 25
20 10 19 9 27 27
17...

output:

-2.935856727586833 -2.000000000000000 -13.352348999857673
-26.206159293104736 -17.770400269788610 -11.125966283811174
-28.027431433359673 -18.318582636182789 -8.243362186282257
-27.043313881402803 -13.391819356908659 -27.018301873523452
-26.534933366925674 -22.066632132649346 -29.616079568529663
-26...

result:

wrong answer 4th numbers differ - expected: '-22.14648', found: '-26.20616', error = '0.18331'