QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#322393#6763. Triangle PendantPetroTarnavskyi#WA 2ms4072kbC++203.0kb2024-02-06 23:10:462024-02-06 23:10:46

Judging History

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

  • [2024-02-06 23:10:46]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:4072kb
  • [2024-02-06 23:10:46]
  • 提交

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 long double db;

const db PI = acos(-1.); 
const db EPS = 1e-5; 

//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 + EPS);
		
		ans[it] = x + m + a/2 * sin(alphaC - PI/2);
		
		swap(b, c);
		swap(y, z);
	}
	
	return MP(ok, ans);
}
pair<bool, vector<db>> check2(db x, db y, db z, db a, db b, db c)
{
	vector<db> ans(3);
	bool ok = 1;
	FOR(it, 0, 2)
	{
		db mA = med(b, c, a);
		db alpha = kut(x, c, y);
		db beta = kut(c, mA, a/2);
		db hama = kut(b, mA, a/2);
		
		db OC = len(x, b, alpha + beta + hama);
		ok &= OC < z + EPS;
		
		db OM = len(x, 2 * mA / 3, alpha + beta);
		db AOM = kut(x, OM, 2 * mA / 3);

		if(it == 0)
		{
			
			db AK = x * sin(AOM) / sin(AOM + alpha + beta + hama);
			db OK = len(x, AK, alpha + beta + hama);
			db COK = kut(OC, OK, b - AK);
			ans[2] = OC * cos(COK);
		}
		
		ans[it] = x * cos(AOM); 
		
		swap(x, y);
		swap(a, b);
	}
	return MP(ok, 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, r[i], 2 * m / 3);
		ans[i] = r[i] * cos(alpha);
	}

	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)
		{
		//	cerr << "Here1\n";
			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)
		{
		//	cerr << "Here2\n";
			print(res.S, i);
			return;
		}
	}
//	cerr << "Here3\n";
	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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4072kb

input:

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

output:

-0.816496580927726 -0.816496580927726 -0.816496580927726
-2.000000000000000 -2.866025403784439 -2.866025403784439

result:

ok 6 numbers

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3972kb

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.935856727586834 -2.000000000000000 -13.352348999857674
-22.146476218003023 -16.076204705476878 -12.241826659011300
-28.027431433359673 -18.318582636182793 -8.243362186282257
-27.266119651334361 -13.159319584325651 -26.882525397692707
-26.534933366925672 -22.066632132649342 -29.616079568529664
-26...

result:

wrong answer 30th numbers differ - expected: '-9.68713', found: '9.68713', error = '2.00000'