QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#194728#7521. Find the Gapucup-team484#WA 235ms3712kbC++172.5kb2023-09-30 21:58:192023-09-30 21:58:19

Judging History

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

  • [2023-09-30 21:58:19]
  • 评测
  • 测评结果:WA
  • 用时:235ms
  • 内存:3712kb
  • [2023-09-30 21:58:19]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

#define rep(i,a,b) for (int i = (a); i < (b); ++i)

template<class T> struct Point3D {
  typedef Point3D P;
  typedef const P& R;
  T x, y, z;
  explicit Point3D(T x=0, T y=0, T z=0) : x(x), y(y), z(z) {}
  bool operator<(R p) const {
    return tie(x, y, z) < tie(p.x, p.y, p.z); }
  bool operator==(R p) const {
    return tie(x, y, z) == tie(p.x, p.y, p.z); }
  P operator+(R p) const { return P(x+p.x, y+p.y, z+p.z); }
  P operator-(R p) const { return P(x-p.x, y-p.y, z-p.z); }
  P operator*(T d) const { return P(x*d, y*d, z*d); }
  P operator/(T d) const { return P(x/d, y/d, z/d); }
  T dot(R p) const { return x*p.x + y*p.y + z*p.z; }
  P cross(R p) const {
    return P(y*p.z - z*p.y, z*p.x - x*p.z, x*p.y - y*p.x);
  }
  T dist2() const { return x*x + y*y + z*z; }
  ld dist() const { return sqrt((ld)dist2()); }
  //Azimuthal angle (longitude) to x-axis in interval [-pi, pi]
  ld phi() const { return atan2(y, x); }
  //Zenith angle (latitude) to the z-axis in interval [0, pi]
  ld theta() const { return atan2(sqrt(x*x+y*y),z); }
  P unit() const { return *this/(T)dist(); } //makes dist()=1
  //returns unit vector normal to *this and p
  P normal(P p) const { return cross(p).unit(); }
  //returns point rotated 'angle' radians ccw around axis
  P rotate(ld angle, P axis) const {
    ld s = sin(angle), c = cos(angle); P u = axis.unit();
    return u*dot(u)*(1-c) + (*this)*c - cross(u)*s;
  }
};

typedef Point3D<ll> P3;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	if (n <= 3) {
		cout << "0.0\n";
		return 0;
	}
	vector<P3> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i].x >> a[i].y >> a[i].z;
	ld ans = 1e18;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				P3 dir = (a[j] - a[i]).cross(a[k] - a[i]);
				int x = 0, y = 0;
				ld cur = 0, len = sqrt(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z);
				for (int l = 0; l < n; l++) {
					ll val = dir.dot(a[l] - a[i]);
					x += val < 0;
					y += val > 0;
					cur = max(cur, (ld)abs(val) / len);
				}
				if (x > 0 && y > 0)
					continue;
				ans = min(ans, cur);
			}
		}
	}
	cout << fixed << setprecision(15) << ans << "\n";
}

详细

Test #1:

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

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

result:

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

Test #2:

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

input:

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

output:

0.707106781186547

result:

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

Test #3:

score: -100
Wrong Answer
time: 235ms
memory: 3620kb

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

result:

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