QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#323518 | #6763. Triangle Pendant | mshcherba | WA | 3ms | 4504kb | C++20 | 3.1kb | 2024-02-09 23:43:46 | 2024-02-09 23:43:46 |
Judging History
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 << c << " " << b << " " << a << "\n";
else
cout << b << " " << a << " " << c << "\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)
{
return (b * b + c * c - a * a) / (2 * b * c);
}
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 (z < DC1 - 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;
if (solve1(x, y, z, a, b, c, 0))
return;
if (solve1(y, z, x, b, c, a, 1))
return;
if (solve1(z, x, y, c, a, b, 2))
return;
if (solve2(x, y, z, a, b, c, 0))
return;
if (solve2(y, z, x, b, c, a, 1))
return;
if (solve2(z, x, y, c, a, b, 2))
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(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: 4244kb
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: 3ms
memory: 4504kb
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 -13.352348999857675 -2.000000000000000 -22.146476218003023 -12.241826659011300 -16.076204705476876 -28.027431433359670 -18.318582636182796 -8.243362186282258 -27.266119651334360 -13.159319584325656 -26.882525397692707 -26.534933366925674 -22.066632132649339 -29.616079568529663 -26...
result:
wrong answer 2nd numbers differ - expected: '-2.00000', found: '-13.35235', error = '5.67617'