QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#236587 | #7521. Find the Gap | Dawn_Sdy | WA | 2ms | 3856kb | C++14 | 1.9kb | 2023-11-04 08:32:26 | 2023-11-04 08:32:26 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define For(i, a, b) for (register int i = (a); i <= (b); ++i)
#define Rof(i, a, b) for (register int i = (a); i >= (b); --i)
#define For_Edge(i, x) for(register int i = head[x]; i; i = edge[i].nex)
#define fi first
#define se second
using namespace std;
inline int read() {
int x = 0;
char c = getchar();
bool f = 0;
while(!isdigit(c)) f |= (c == '-'), c = getchar();
while(isdigit(c)) x = (x * 10) + (c ^ 48), c = getchar();
return f ? -x : x;
}
inline void Checkmin(int &x, int y) { x = x < y ? x : y; }
inline void Checkmax(int &x, int y) { x = x > y ? x : y; }
const int maxn = 55;
const double INF = 1e18 + 7.0;
int n;
double Answer;
struct node {
int x, y, z;
}Point[maxn];
inline node operator - (node x, node y) { return (node){x.x - y.x, x.y - y.y, x.z - y.z}; }
inline int operator ^ (node x, node y) { return x.x * y.x + x.y * y.y + x.z * y.z; }
inline node operator * (node x, node y) { return (node){x.y * y.z - x.z * y.y, x.z * y.x - x.x * y.z, x.x * y.y - x.y * y.x}; }
inline void Init() {
n = read();
For(i, 1, n) Point[i].x = read(), Point[i].y = read(), Point[i].z = read();
}
inline void Calc(node P) {
if(!(P ^ P)) return ;
int minn = INF, maxx = -INF;
For(i, 1, n) Checkmin(minn, P ^ Point[i]), Checkmax(maxx, P ^ Point[i]);
Answer = fmin(Answer, 1.0 * (maxx - minn) / sqrt(1.0 * (P ^ P)));
}
inline void Solve() {
Answer = INF;
For(i, 1, n) {
For(j, i + 1, n) {
For(i2, i, n) {
For(j2, i2 + 1, n) {
node P1 = Point[j] - Point[i], P2 = Point[j2] - Point[i2], P = P1 * P2;
Calc(P);
}
}
}
}
if(Answer >= INF) printf("-1\n");
else printf("%0.12lf\n", Answer);
}
signed main() {
// freopen("J.in", "r", stdin);
// freopen("J.out", "w", stdout);
Init(), Solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
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.000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
5 1 1 1 1 2 1 1 1 2 1 2 2 2 1 1
output:
0.707106781187
result:
ok found '0.707106781', expected '0.707106781', error '0.000000000'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3624kb
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:
-1
result:
wrong answer 1st numbers differ - expected: '0.0000000', found: '-1.0000000', error = '1.0000000'