QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325896#6763. Triangle PendantmshcherbaWA 3ms4348kbC++203.3kb2024-02-12 03:44:552024-02-12 03:44:56

Judging History

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

  • [2024-02-12 03:44:56]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4348kb
  • [2024-02-12 03:44:55]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); 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 EPS = 1e-9;

void print(db a, db b, db c, int i)
{
	if (i == 0)
		cout << a << " " << b << " " << c << "\n";
	else if (i == 1)
		cout << b << " " << c << " " << a << "\n";
	else
		cout << c << " " << a << " " << b << "\n";
}

db getMedian(db a, db b, db c)
{
	return sqrt(2 * (b * b + c * c) - a * a) / 2;
}

db getCos(db a, db b, db c)
{
	db res = (b * b + c * c - a * a) / (2 * b * c);
	assert(-1 - EPS < res && res < 1 + EPS);
	return res;
}

db getThirdSide(db b, db c, db co)
{
	return sqrt(b * b + c * c - 2 * b * c * co);
}

bool solve1(db x, db y, db z, db a, db b, db c, int i)
{
	db m = getMedian(a, b, c);
	db coB = getCos(a / 2, b, m), coC = getCos(a / 2, c, m);
	db hb = -x - c * coC, hc = -x - b * coB;
	if (getThirdSide(x, c, -coC) > y + EPS || getThirdSide(x, b, -coB) > z + EPS)
		return false;
	print(-x, hb, hc, i);
	return true;
}

bool solve2(db x, db y, db z, db a, db b, db c, int i)
{
	if (2 * max({x, y, c}) > x + y + c + EPS)
		return false;
	db mA = getMedian(a, b, c), mB = getMedian(b, c, a), mC = getMedian(c, a, b);
	db AM = 2 * mA / 3, BM = 2 * mB / 3, CM = 2 * mC / 3;
	db MAB = acos(getCos(BM, AM, c)), MBA = acos(getCos(AM, BM, c));
	db DAB = acos(getCos(y, x, c)), DBA = acos(getCos(x, y, c));
	db DM1 = getThirdSide(x, AM, cos(MAB + DAB));
	db DM2 = getThirdSide(y, BM, cos(MBA + DBA));
	assert(abs(DM1 - DM2) < EPS);
	db CAB = acos(getCos(a, b, c)), CBA = acos(getCos(b, a, c));
	db DC1 = getThirdSide(x, b, cos(CAB + DAB));
	db DC2 = getThirdSide(y, a, cos(CBA + DBA));
	assert(abs(DC1 - DC2) < EPS);
	if (DC1 > z + EPS || abs(acos(getCos(c, x, y)) - acos(getCos(AM, x, DM1)) - acos(getCos(BM, y, DM2))) > EPS)
		return false;
	db cosCDM = getCos(CM, DM1, DC1);
	print(-x * getCos(AM, x, DM1), -y * getCos(BM, y, DM2), -DC1 * cosCDM, i);
	return true;
}

pair<db, db> getH(db x, db y, db z, db a, db b, db c)
{
	db ma = getMedian(a, y, z), mA = getMedian(a, b, c);
	db cosA = getCos(ma, x, mA);
	db l = getThirdSide(2 * mA / 3, x, cosA);
	cosA = getCos(2 * mA / 3, x, l);
	return {-x * cosA, l};
}

void solve()
{
	db x, y, z, a, b, c;
	cin >> x >> y >> z >> a >> b >> c;
	int ok1 = 0, ok2 = 0;
	if (solve1(x, y, z, a, b, c, 0))
		ok1++;
	if (solve1(y, z, x, b, c, a, 1))
		ok1++;
	if (solve1(z, x, y, c, a, b, 2))
		ok1++;
	assert(ok1 <= 1);
	if (ok1)
		return;
	if (solve2(x, y, z, a, b, c, 0))
		ok2++;
	if (solve2(y, z, x, b, c, a, 1))
		ok2++;
	if (solve2(z, x, y, c, a, b, 2))
		ok2++;
	assert(ok2 <= 1);
	if (ok2)
		return;
	auto [ans1, l1] = getH(x, y, z, a, b, c);
	auto [ans2, l2] = getH(y, z, x, b, c, a);
	auto [ans3, l3] = getH(z, x, y, c, a, b);
	assert(abs(l2 - l1) < EPS && abs(l3 - l1) < EPS);
	cout << ans1 << " " << ans2 << " " << ans3 << "\n";
}

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

详细

Test #1:

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

input:

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

output:

-0.8164966 -0.8164966 -0.8164966
-2.0000000 -2.8660254 -2.8660254

result:

ok 6 numbers

Test #2:

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

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:

-13.3523490 -2.9358567 -2.0000000
-12.2418267 -22.1464762 -16.0762047
-28.0274314 -18.3185826 -8.2433622
-27.2661197 -13.1593196 -26.8825254
-26.5349334 -22.0666321 -29.6160796
-26.9678045 -12.5576694 -14.1867221
-15.7785957 -20.8626769 -5.1558565
-10.9331000 -21.9155817 -17.7773984
-15.7407388 -18....

result:

wrong answer 1st numbers differ - expected: '-2.93586', found: '-13.35235', error = '3.54802'