QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#547007#7523. Partially Free MealOIer_kzcWA 0ms1768kbC++171.7kb2024-09-04 16:45:112024-09-04 16:45:12

Judging History

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

  • [2024-09-04 16:45:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1768kb
  • [2024-09-04 16:45:11]
  • 提交

answer

#include <stdio.h>
#include <string.h>

#include <cmath>
#include <algorithm>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long LL;
typedef long double LDB;
constexpr int N = 55;

int n;
struct Vec {
	LL x, y, z;
	void write() {
		printf("(%lld, %lld, %lld)\n", x, y, z);
	}
	Vec operator - (const Vec &t) const {
		return (Vec){x - t.x, y - t.y, z - t.z};
	}
	Vec operator * (const Vec &t) const {
		return (Vec){y * t.z - z * t.y, z * t.x - x * t.z, x * t.y - y * t.x};
	}
	void operator += (const Vec &t) {
		x += t.x, y += t.y;
	}
	void operator -= (const Vec &t) {
		x -= t.x, y -= t.y;
	}
	LL operator & (const Vec &t) const {
		return x * t.x + y * t.y + z * t.z;
	}
	LL md2() const {
		return x * x + y * y + z * z;
	}
	LDB md() const {
		return sqrtl(x * x + y * y + z * z);
	}
} w[N], ve[N * N]; int szv;
LDB res = 1e36;

int main() {
	scanf("%d", &n);
	if (n < 4) {
		puts("0.000000000000000");
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		scanf("%lld%lld%lld", &w[i].x, &w[i].y, &w[i].z);
	}
	bool yes = true;
	for (int i = 1; i < n; ++i) {
		for (int j = 1; j < n; ++j) {
			if (((w[i] - w[0]) * (w[j] - w[0])).md2()) {
				yes = false;
			}
		}
	}
	if (yes) {
		puts("0.000000000000000");
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			ve[szv++] = w[j] - w[i];
		}
	}
	for (int i = 0; i < szv; ++i) {
		for (int j = i + 1; j < szv; ++j) {
			Vec m = ve[i] * ve[j];
			LL maxv = 0ll, minv = 0ll;
			for (int k = 0; k < n; ++k) {
				LL v = w[i] & m;
				maxv = max(maxv, v);
				minv = min(minv, v);
			}
			res = min(res, (maxv - minv) / m.md());
		}
	}
	printf("%.15Lf\n", res);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1768kb

input:

3
2 5
4 3
3 7

output:

0.000000000000000

result:

wrong answer 1st lines differ - expected: '7', found: '0.000000000000000'