QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#232047 | #7065. Triangle | Ronbogo# | AC ✓ | 1128ms | 3872kb | C++20 | 1.5kb | 2023-10-29 19:41:17 | 2023-10-29 19:41:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
FILE* __ = freopen("in.txt", "r", stdin);
#endif
#define LL long long
#define LD long double
int x[4], y[4], px, py;
bool pd(int x1, int y1, int x2, int y2) {
LL xx = px - x1, yy = py - y1, xxx = x2 - px, yyy = y2 - py;
if (xx * yyy - xxx * yy != 0) return 0;
if (1ll * (x1 - px) * (px - x2) < 0) return 0;
if (1ll * (y1 - py) * (py - y2) < 0) return 0;
return 1;
}
LL dis(int x, int y, int px, int py) {
return 1ll * (x - px) * (x - px) + 1ll * (y - py) * (y - py);
}
LD f(LD x1, LD x2, LD k) { return x1 + (x2 - x1) * k / 2.0; }
void sol() {
for (int i = 1; i <= 3; ++i) cin >> x[i] >> y[i];
cin >> px >> py;
if (pd(x[1], y[1], x[2], y[2])) {
} else if (pd(x[1], y[1], x[3], y[3])) {
swap(x[2], x[3]);
swap(y[2], y[3]);
} else if (pd(x[2], y[2], x[3], y[3])) {
swap(x[1], x[3]);
swap(y[1], y[3]);
} else {
cout << -1 << '\n';
return;
}
if (dis(x[1], y[1], px, py) <= dis(x[2], y[2], px, py))
swap(x[1], x[2]), swap(y[1], y[2]);
LD k = sqrt(1.0 * dis(x[1], y[1], x[2], y[2]) / dis(x[1], y[1], px, py));
// cout << k << '\n';
cout << setprecision(30) << f(x[1], x[3], k) << ' ' << f(y[1], y[3], k)
<< '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int _ = 1;
cin >> _;
while (_--) sol();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
2 0 0 1 1 1 0 1 0 0 0 1 1 1 0 2 0
output:
0.5 0.5 -1
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 569ms
memory: 3820kb
input:
999966 9456 15557 18451 3957 6242 20372 9855 5351 30245 31547 9979 4703 25914 19144 26670 11383 13855 0 24614 0 15860 11017 12445 0 27870 17680 4219 3554 9129 29072 28316 17893 3249 27269 12754 4923 31746 16860 14894 21576 6846 0 1915 0 25023 28721 10508 0 10110 11862 23224 10373 17715 8212 29474 11...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 21424.6814794177058338675578852 13086.0539109841890672569775234 -1 -1 18711.2379903040990321017034148 10162.3763772587053608731366694 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 28212.9521348925755610537180473 245.8177862387816273725...
result:
ok 1111378 numbers
Test #3:
score: 0
Accepted
time: 549ms
memory: 3824kb
input:
999974 9228 16833 13143 23461 5117 7645 21359 13652 21313 3160 20333 1620 16288 7781 13315 10132 4372 0 27536 0 3207 8695 9983 0 21469 29998 19948 29904 30517 11141 14857 12881 11116 29172 16833 32095 18915 9448 22043 12275 32131 0 14304 0 16638 29018 2048 0 4695 4823 14130 2496 32676 4092 6363 2476...
output:
-1 -1 11482.9903720161792994858274142 5737.22383638124546800796110801 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 15409.8418549346002723865467487 12451.4278636543809684056327569 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 10828.9713857795993376953447296 25347.33485732...
result:
ok 1110866 numbers
Test #4:
score: 0
Accepted
time: 1128ms
memory: 3872kb
input:
1000000 54242 34392 23333 92971 5711 47765 54242 34392 24492 41078 36756 68794 2060 62118 14678 50283 12685 18891 59613 23256 26016 46755 59613 23256 85238 49611 95092 85360 45143 87657 95092 85360 72852 37174 39825 60628 32289 18423 72852 37174 95309 61613 1645 45877 78395 38196 95309 61613 92215 7...
output:
14522 70368 32900.8888888888871768756416714 68052.222222222221894583071844 19350.5 32823 65190.5 68634 36057 39525.5 40020 42036.5 95183.5 40970.5 28582 94834.5 55598 59174 19727 68648 73385 43885.5 16465.9999999999982236431605997 56484.8999999999990926369264344 40447 23197.5 34665.33333333333651182...
result:
ok 2000000 numbers