QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#216700#7065. Triangle4k2kokAC ✓1225ms3912kbC++203.0kb2023-10-15 21:08:032023-10-15 21:08:04

Judging History

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

  • [2023-10-15 21:08:04]
  • 评测
  • 测评结果:AC
  • 用时:1225ms
  • 内存:3912kb
  • [2023-10-15 21:08:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
#define eps 1e-12
#define zero(x) (((x)>0?(x):(-x))<eps)

struct point{
    long long x, y;
}p[4];

long long xmult(point p1, point p2, point p0) {
    return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
}

int dot_online_in(point p, point l1, point l2) {
    return zero(xmult(p, l1, l2)) && (l1.x - p.x) * (l2.x - p.x) < eps && (l1.y - p.y) * (l2.y - p.y) < eps;
}

void run(point aa, point bb, point cc) {
    if (abs(p[0].x - aa.x) == abs(p[0].x - bb.x)) {
        if (abs(p[0].y - aa.y) == abs(p[0].y - bb.y)) {
            cout << fixed << setprecision(10) << (double)cc.x << " " << (double)cc.y << '\n';
        } else if (abs(p[0].y - aa.y) < abs(p[0].y - bb.y)) {
            int a = abs(p[0].y - bb.y);
            int b = abs(bb.y - aa.y);
            int c = a;
            a = b;
            b = 2 * c;
            double ansx, ansy;
            ansx = (double)(cc.x - bb.x) * 1.0 / b * a + bb.x;
            ansy = (double)(cc.y - bb.y) * 1.0 / b * a + bb.y;
            cout << fixed << setprecision(10) << ansx << " " << ansy << '\n';
        } else {
            int a = abs(p[0].y - aa.y);
            int b = abs(aa.y - bb.y);
            int c = a;
            a = b;
            b = 2 * c;
            double ansx, ansy;
            ansx = (double)(cc.x - aa.x) * 1.0 / b * a + aa.x;
            ansy = (double)(cc.y - aa.y) * 1.0 / b * a + aa.y;
            cout << fixed << setprecision(10) << ansx << " " << ansy << '\n';
        }
    } else {
        if(abs(p[0].x - aa.x) <= abs(p[0].x - bb.x) && abs(p[0].y - aa.y) <= abs(p[0].y - bb.y)) {
            int a = abs(p[0].x - bb.x);
            int b = abs(bb.x - aa.x);
            int c = a;
            a = b;
            b = 2 * c;
            double ansx, ansy;
            ansx = (double)(cc.x - bb.x) * 1.0 / b * a + bb.x;
            ansy = (double)(cc.y - bb.y) * 1.0 / b * a + bb.y;
            cout << fixed << setprecision(10) << ansx << " " << ansy << '\n';
        } else {
            int a = abs(p[0].x - aa.x);
            int b = abs(aa.x - bb.x);
            int c = a;
            a = b;
            b = 2 * c;
            double ansx, ansy;
            ansx = (double)(cc.x - aa.x) * 1.0 / b * a + aa.x;
            ansy = (double)(cc.y - aa.y) * 1.0 / b * a + aa.y;
            cout << fixed << setprecision(10) << ansx << " " << ansy << '\n';
        }
    }
}

void solve() {
    for(int i = 1; i <= 3; i++) 
        cin >> p[i].x >> p[i].y;
    cin >> p[0].x >> p[0].y;
    if(dot_online_in(p[0], p[2], p[1])) run(p[1], p[2], p[3]);
    else if(dot_online_in(p[0], p[3], p[1])) run(p[1], p[3], p[2]);
    else if(dot_online_in(p[0], p[2], p[3])) run(p[2], p[3], p[1]);
    else cout << "-1\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3892kb

input:

2
0 0 1 1 1 0 1 0
0 0 1 1 1 0 2 0

output:

0.5000000000 0.5000000000
-1

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 504ms
memory: 3848kb

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.6814794177 13086.0539109842
-1
-1
18711.2379903041 10162.3763772587
-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.9521348926 245.8177862388
-1
-1
-1
-1
-1
-1
-1
-1
22604.5753021888 14546.1287161058
-1
-1
11557.3465218992 46...

result:

ok 1111378 numbers

Test #3:

score: 0
Accepted
time: 493ms
memory: 3912kb

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.9903720162 5737.2238363812
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
15409.8418549346 12451.4278636544
-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.9713857796 25347.3348573230
-1
-1
-1
-1
-1
18768.6726994647 12151.3671509899
-1
-1
-1
-1
-1
10801.120...

result:

ok 1110866 numbers

Test #4:

score: 0
Accepted
time: 1225ms
memory: 3832kb

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.0000000000 70368.0000000000
32900.8888888889 68052.2222222222
19350.5000000000 32823.0000000000
65190.5000000000 68634.0000000000
36057.0000000000 39525.5000000000
40020.0000000000 42036.5000000000
95183.5000000000 40970.5000000000
28582.0000000000 94834.5000000000
55598.0000000000 59174.00000...

result:

ok 2000000 numbers