QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645161#9434. Italian CuisineDjangle162857WA 37ms3768kbC++144.7kb2024-10-16 17:06:282024-10-16 17:06:30

Judging History

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

  • [2024-10-16 17:06:30]
  • 评测
  • 测评结果:WA
  • 用时:37ms
  • 内存:3768kb
  • [2024-10-16 17:06:28]
  • 提交

answer

#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'

#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif

#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif

#ifdef LOCAL
#define debugv(x)                   \
	cerr << setw(4) << #x << ":: "; \
	for (auto i : x)                \
		cerr << i << " ";           \
	cerr << endl
#else
#define debugv(x)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
	out << x.fir << " " << x.sec << endl;
	return out;
}

using point_t = long double;
constexpr point_t eps = 1e-14;
constexpr point_t INF = numeric_limits<point_t>::max();

template <typename T>
struct point {
	T x, y;

	bool operator==(const point& a) const
	{
		return (abs(x - a.x) <= eps && abs(y - a.y) <= eps);
	}
	bool operator<(const point& a) const
	{
		if (abs(x - a.x) <= eps)
			return y < a.y - eps;
		return x < a.x - eps;
	}
	bool operator>(const point& a) const
	{
		return !(*this < a || *this == a);
	}
	point operator+(const point& a) const
	{
		return {x + a.x, y + a.y};
	}
	point operator-(const point& a) const
	{
		return {x - a.x, y - a.y};
	}
	point operator-() const
	{
		return {-x, -y};
	}
	point operator*(const T k) const
	{
		return {k * x, k * y};
	}
	point operator/(const T k) const
	{
		return {x / k, y / k};
	}
	T operator*(const point& a) const
	{
		return x * a.x + y * a.y;
	}
	T operator^(const point& a) const
	{
		return x * a.y - y * a.x;
	}
	int toleft(const point& a) const
	{
		const auto t = (*this) ^ a;
		return (t > eps) - (t < -eps);
	}
	T len2() const
	{
		return (*this) * (*this);
	}
	T dis2(const point& a) const
	{
		return (a - (*this)).len2();
	}

	long double len() const
	{
		return sqrtl(len2());
	}
	long double dis(const point& a) const
	{
		return sqrtl(dis2(a));
	}
};
using Point = point<point_t>;

template <typename T>
struct line {
	point<T> p, v;
	int toleft(const point<T>& a) const
	{
		return v.toleft(a - p);
	}
	long double dis(const point<T>& a) const
	{
		return abs(v ^ (a - p)) / v.len();
	}
};
using Line = line<point_t>;
struct circle {
	Point c;
	long double r;
	int isin(const Point& p) const
	{
		const long double d = p.dis(c);
		return abs(d - r) <= eps ? -1 : d < r - eps;
	}
	int relation(const Line& l) const
	{
		const long double d = l.dis(c);
		if (d > r + eps)
			return 0;
		if (abs(d - r) <= eps)
			return 1;
		return 2;
	}
};
template <typename T>
struct polygon {
	vector<point<T>> p;
	size_t nxt(const size_t i) const
	{
		return i == p.size() - 1 ? 0 : i + 1;
	}
	size_t pre(const size_t i) const
	{
		return i == 0 ? p.size() - 1 : i - 1;
	}
	T area() const
	{
		T sum = 0;
		for (size_t i = 0; i < p.size(); i++) {
			sum += p[i] ^ p[nxt(i)];
		}
		return sum;
	}
};
using Polygon = polygon<point_t>;
void solve()
{
	int n;
	cin >> n;
	circle c;
	cin >> c.c.x >> c.c.y >> c.r;
	Line l;
	Polygon pol;
	for (int i = 0; i < n; i++) {
		Point p;
		cin >> p.x >> p.y;
		// cout << i << " " << p.x << " " << p.y << endl;
		pol.p.push_back(p);
	}
	// cout << pol.area() << endl;
	int ed = 1;
	ll nowarea = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		if (ed == i) {
			assert(nowarea == 0);
			ed = (i + 1) % n;
		}
		while (1) {
			// debug(i);
			int now = (ed + 1) % n;
			// debug(now);
			Line l = {pol.p[i], pol.p[now] - pol.p[i]};
			Line l1 = {pol.p[i], pol.p[ed] - pol.p[i]};
			/*FINISH
			debug(ed);
			cout << pol.p[ed].x << " " << pol.p[ed].y << endl;
			cout << pol.p[now].x << " " << pol.p[now].y << endl;*/
			Polygon P;
			/*cout << l.p.x << " " << l.p.y << " " << l.v.x << " " << l.v.y
				 << endl;
			cout << l.dis(c.c) << endl;
			cout << c.relation(l) << endl;*/
			if (c.relation(l) != 0 || (l.toleft(c.c) != l1.toleft(c.c))) {
				P.p.push_back(pol.p[i]);
				P.p.push_back(pol.p[(i + 1) % n]);
				P.p.push_back(pol.p[ed]);
				nowarea -= abs(P.area());
				break;
			}
			P.p.push_back(pol.p[i]);
			P.p.push_back(pol.p[ed]);
			P.p.push_back(pol.p[now]);
			nowarea += P.area();
			ans = max(ans, nowarea);
			ed = now;
		}
		/*cout << char('A' + i) << " " << char('A' + ed) << " " << nowarea << "
		   "
			 << ans << endl;*/
	}

	cout << ans << el;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
/*
1
16
7 3 3
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
7 10
*/

詳細信息

Test #1:

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

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
24
0

result:

ok 3 number(s): "5 24 0"

Test #2:

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

input:

1
6
0 0 499999993
197878055 -535013568
696616963 -535013568
696616963 40162440
696616963 499999993
-499999993 499999993
-499999993 -535013568

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Wrong Answer
time: 37ms
memory: 3712kb

input:

6666
19
-142 -128 26
-172 -74
-188 -86
-199 -157
-200 -172
-199 -186
-195 -200
-175 -197
-161 -188
-144 -177
-127 -162
-107 -144
-90 -126
-87 -116
-86 -104
-89 -97
-108 -86
-125 -80
-142 -74
-162 -72
16
-161 -161 17
-165 -190
-157 -196
-154 -197
-144 -200
-132 -200
-128 -191
-120 -172
-123 -163
-138...

output:

5093
2862
2539
668
3535
7421
4883
5711
5624
1034
2479
3920
4372
2044
4996
5070
2251
4382
4175
1489
1154
3231
4038
1631
5086
14444
1692
6066
687
1512
4849
5456
2757
8341
8557
8235
1013
5203
10853
6042
6300
4480
2303
2728
1739
2187
3385
4266
6322
909
4334
1518
948
5036
1449
2376
3180
4810
1443
1786
47...

result:

wrong answer 2nd numbers differ - expected: '3086', found: '2862'