QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#223692 | #7065. Triangle | veg# | AC ✓ | 1341ms | 3988kb | C++14 | 1.0kb | 2023-10-22 15:21:23 | 2023-10-22 15:21:24 |
Judging History
answer
#include<bits/stdc++.h>
#define db long double
const db eps=1e-8;
using namespace std;
struct xl{
db x,y;
};
xl operator -(xl i,xl j) {
return (xl){i.x-j.x,i.y-j.y};
}
xl operator +(xl i,xl j) {
return (xl){i.x+j.x,i.y+j.y};
}
xl operator *(db i,xl j) {
return (xl){i*j.x,i*j.y};
}
db operator ^(xl i,xl j) {
return i.x*j.x+i.y*j.y;
}
db dis(xl i) {
return sqrt(i^i);
}
bool check(xl a,xl b,xl c) {
xl x=c-a,y=c-b;
return abs((x^y)+dis(x)*dis(y))<=eps;
}
int main() {
int T; scanf("%d",&T);
while(T--) {
xl a,b,c,d;
scanf("%Lf%Lf%Lf%Lf%Lf%Lf%Lf%Lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y);
if(check(a,c,d)) {
swap(b,c);
} else if(check(b,c,d)) {
swap(a,c);
}
if(!check(a,b,d)) {
puts("-1"); continue;
}
db k1=dis(a-d)/dis(a-b);
xl ans=(xl){0,0};
if(k1<=eps) {
ans=b+0.5*(c-b);
} else {
if(k1<0.5) {
swap(b,a);
k1=1.0-k1;
}
db k2=0.5/k1;
ans=a+k2*(c-a);
}
printf("%.12Lf %.12Lf\n",ans.x,ans.y);
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3920kb
input:
2 0 0 1 1 1 0 1 0 0 0 1 1 1 0 2 0
output:
0.500000000000 0.500000000000 -1
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 699ms
memory: 3928kb
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.681479417706 13086.053910984189 -1 -1 18711.237990304099 10162.376377258704 -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.952134892575 245.817786238782 -1 -1 -1 -1 -1 -1 -1 -1 22604.575302188827 14546.128716105848 -1 -1 115...
result:
ok 1111378 numbers
Test #3:
score: 0
Accepted
time: 688ms
memory: 3976kb
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.990372016180 5737.223836381245 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 15409.841854934602 12451.427863654380 -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.971385779600 25347.334857323033 -1 -1 -1 -1 -1 18768.672699464695 12151.367150989889 -1 -1 -1...
result:
ok 1110866 numbers
Test #4:
score: 0
Accepted
time: 1341ms
memory: 3988kb
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.000000000000 70368.000000000000 32900.888888888889 68052.222222222222 19350.500000000000 32823.000000000000 65190.500000000000 68634.000000000000 36057.000000000000 39525.500000000000 40020.000000000000 42036.500000000000 95183.500000000000 40970.500000000000 28582.000000000000 94834.500000000...
result:
ok 2000000 numbers