QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#336642#7521. Find the GapMarch_AprilWA 1ms3808kbC++171.4kb2024-02-24 18:37:222024-02-24 18:37:23

Judging History

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

  • [2024-02-24 18:37:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3808kb
  • [2024-02-24 18:37:22]
  • 提交

answer

#include <iostream>
#include <cmath>

using namespace std;

const int N = 55;

struct Point
{
    int x, y, z;
    Point operator - (Point a)
    {
        return { x - a.x, y - a.y, z - a.z };
    }
    Point operator * (Point a)
    {
        return { y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x };
    }
    int operator & (Point a)
    {
        return x * a.x + y * a.y + z * a.z;
    }
}p[N];

double len(Point a)
{
    return sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
}

int main()
{
    int n;
    cin >> n;

    for(int i = 1; i <= n; i ++)
        cin >> p[i].x >> p[i].y >> p[i].z;

    int cnt = 0;
    double ans = 1e18;
    for(int i = 1; i <= n; i ++)
        for(int j = i + 1; j <= n; j ++)
            for(int k = j + 1; k <= n; k ++)
                for(int t = k + 1; t <= n; t ++)
                {
                    Point p1 = p[j] - p[i], p2 = p[t] - p[k], v = p1 * p2;
                    if(!v.x && !v.y && !v.z)    continue;

                    double mi = 1e18, mx = -1e18;
                    for(int x = 1; x <= n; x ++)
                    {
                        double l = (p[x] & v) / len(v);
                        mi = min(mi, l), mx = max(mx, l);
                    }

                    ans = min(ans, mx - mi);
                }

    printf("%.11lf", ans);

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8
1 1 1
1 1 2
1 2 1
1 2 2
2 1 1
2 1 2
2 2 1
2 2 2

output:

1.00000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

5
1 1 1
1 2 1
1 1 2
1 2 2
2 1 1

output:

0.70710678119

result:

ok found '0.707106781', expected '0.707106781', error '0.000000000'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3792kb

input:

50
973 1799 4431
1036 1888 4509
1099 1977 4587
1162 2066 4665
1225 2155 4743
1288 2244 4821
1351 2333 4899
1414 2422 4977
1540 2600 5133
1603 2689 5211
1666 2778 5289
1729 2867 5367
1792 2956 5445
1855 3045 5523
1918 3134 5601
1981 3223 5679
2044 3312 5757
2107 3401 5835
2170 3490 5913
2296 3668 606...

output:

1000000000000000000.00000000000

result:

wrong answer 1st numbers differ - expected: '0.0000000', found: '1000000000000000000.0000000', error = '1000000000000000000.0000000'