QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#195254 | #7521. Find the Gap | ucup-team1716# | WA | 1ms | 3912kb | C++20 | 1.4kb | 2023-10-01 02:43:27 | 2023-10-01 02:43:27 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed << setprecision(13);
int n;
cin >> n;
vector<double> x(n), y(n), z(n);
for(int i=0; i<n; i++) cin >> x[i] >> y[i] >> z[i];
double ans = 10000;
for(int i=0; i<n; i++)
{
for(int j=i+1; j<n; j++)
{
double v1_x = x[i]-x[j], v1_y = y[i]-y[j], v1_z = z[i]-z[j];
for(int k=j+1; k<n; k++)
{
double v2_x = x[i]-x[k], v2_y = y[i]-y[k], v2_z = z[i]-z[k];
double v1xv2_x = v1_y*v2_z-v2_y*v1_z, v1xv2_y = v1_z*v2_x-v2_z*v1_x, v1xv2_z = v1_x*v2_y-v2_x*v1_y;
double len = sqrt(v1xv2_x*v1xv2_x + v1xv2_y*v1xv2_y + v1xv2_z*v1xv2_z);
double M = 0, m = 0;
for(int l=0; l<n; l++)
{
//cout << i << j << k << l << " " << ((x[l]-x[i])*v1xv2_x + (y[l]-y[i])*v1xv2_y + (z[l]-z[i])*v1xv2_z)/len << "\n";
M = max(M, ((x[l]-x[i])*v1xv2_x + (y[l]-y[i])*v1xv2_y + (z[l]-z[i])*v1xv2_z)/len);
m = min(m, ((x[l]-x[i])*v1xv2_x + (y[l]-y[i])*v1xv2_y + (z[l]-z[i])*v1xv2_z)/len);
}
ans = min(ans, M - m);
}
}
}
cout << ans;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3912kb
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.0000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
5 1 1 1 1 2 1 1 1 2 1 2 2 2 1 1
output:
0.7071067811865
result:
ok found '0.707106781', expected '0.707106781', error '0.000000000'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3808kb
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:
-nan
result:
wrong output format Expected double, but "-nan" found