QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#195268#7521. Find the Gapucup-team180#WA 3ms3784kbC++171.5kb2023-10-01 02:54:212023-10-01 02:54:22

Judging History

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

  • [2023-10-01 02:54:22]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3784kb
  • [2023-10-01 02:54:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000;
struct point{
  long long x, y, z;
  point(){
  }
  point(long long x, long long y, long long z): x(x), y(y), z(z){
  }
  point operator -(point P){
    return point(x - P.x, y - P.y, z - P.z);
  }
};
double abs(point P){
  return hypot(P.x, P.y, P.z);
}
long long dot(point P, point Q){
  return P.x * Q.x + P.y * Q.y + P.z * Q.z;
}
point cross(point P, point Q){
  return point(P.y * Q.z - P.z * Q.y, P.z * Q.x - P.x * Q.z, P.x * Q.y - P.y * Q.x);
}
int main(){
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<point> P(n);
  for (int i = 0; i < n; i++){
    cin >> P[i].x >> P[i].y >> P[i].z;
  }
  if (n <= 3){
    cout << 0 << endl;
  } else {
    vector<point> C;
    for (int i = 0; i < n; i++){
      for (int j = i + 1; j < n; j++){
        C.push_back(P[j] - P[i]);
      }
    }
    int cnt = C.size();
    for (int i = 0; i < cnt; i++){
      for (int j = i + 1; j < cnt; j++){
        point tmp = cross(C[i], C[j]);
        if (abs(tmp) != 0){
          C.push_back(tmp);
        }
      }
    }
    cnt = C.size();
    double ans = INF;
    for (int i = 0; i < cnt; i++){
      long long mn = INF, mx = -INF;
      for (int j = 0; j < n; j++){
        long long x = dot(C[i], P[j]);
        mn = min(mn, x);
        mx = max(mx, x);
      }
      ans = min(ans, (mx - mn) / abs(C[i]));
    }
    cout << ans << endl;
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3720kb

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.00000000000000000000

result:

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

Test #2:

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

input:

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

output:

0.70710678118654746172

result:

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

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 3784kb

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:

7373.69310454401693277759

result:

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