QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#606372#9434. Italian CuisineLeonaRagingWA 1ms6696kbC++231.9kb2024-10-03 02:11:502024-10-03 02:11:50

Judging History

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

  • [2024-10-03 02:11:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6696kb
  • [2024-10-03 02:11:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define db(val) "[" #val " = " << (val) << "] "

const int maxn = 2e5 + 4;

using T = long long;
using i128 = __int128;

T R;

struct pt {
	T x, y;
	pt (T x = 0, T y = 0): x(x), y(y) {}
	pt operator - (pt o) { return pt(x - o.x, y - o.y);}
	bool operator == (pt o) { return x == o.x && y == o.y;}
	bool operator != (pt o) {return x != o.x || y != o.y;}
};

T dot(pt p, pt q) {return p.x * q.x + p.y * q.y;}

T cross(pt p, pt q) {return p.x * q.y - p.y * q.x;}

T abs(pt p) {return p.x * p.x + p.y * p.y;}

T orient(pt a, pt b, pt c) {return cross(b - a, c - a);}

struct line {
	pt v; T c;
	
	line(pt p, pt q): v(q - p), c(cross(v, p)) {};
	
	bool cmpProj(pt p, pt q) {
		return dot(v, p) < dot(v, q);
	}
	
	T side(pt p) {return cross(v, p) - c;}
	
	T dist(pt p) {return (abs(side(p)) * abs(side(p)) - 1) / abs(v);}
};

T segPoint(pt a, pt b, pt p) {
	line l(a, b);
	i128 u = abs(l.side(p)), v = abs(l.v), r = R;
	u = (u * u - 1) / v;
	r *= r;
	return u > r;
}

int n;
pt C, a[maxn];

void Solve() {
	cin >> n >> C.x >> C.y >> R;
	for (int i = 1; i <= n; i++)
		cin >> a[i].x >> a[i].y;
	for (int i = n + 1; i <= 2 * n; i++)
		a[i] = a[i - n];
	int j = 1;
	T res = 0, cur = 0;
	for (int i = 1; i <= n; i++) {	
		// clog << segPoint()
		while (orient(a[i], a[j + 1], C) > 0 && segPoint(a[i], a[j + 1], C)) {
			cur += abs(cross(a[i], a[j]) + cross(a[j], a[j + 1]) + cross(a[j + 1], a[i]));
			j++;
		}
		res = max(res, cur);
		// clog << i << ' ' << j << ' ' << cur << endl;
		if (i < j) cur -= abs(cross(a[i], a[i + 1]) + cross(a[i + 1], a[j]) + cross(a[j], a[i]));
		else j = i + 1;
	}
	cout << res << '\n';
	// line l(a[3], a[4]);
	// clog << abs(l.v);
	// clog << segPoint(a[3], a[4], C);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t; cin >> t;
    while (t--) {
    	Solve();
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6696kb

input:

3
5
1 1 1
0 0
1 0
5 0
3 3
0 5
6
2 4 1
2 0
4 0
6 3
4 6
2 6
0 3
4
3 3 1
3 0
6 3
3 6
0 3

output:

5
12
0

result:

wrong answer 2nd numbers differ - expected: '24', found: '12'