QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#645037 | #9434. Italian Cuisine | Djangle162857 | WA | 0ms | 3752kb | C++14 | 4.5kb | 2024-10-16 16:38:38 | 2024-10-16 16:38:49 |
Judging History
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-8;
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;
pol.p.push_back(p);
}
// cout << pol.area() << endl;
int ed = 1;
ll nowarea = 0, ans = 0;
for (int i = 0; i < n; i++) {
ed = max(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) == 2 || (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 -= 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 << i << " " << ed << 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: 3752kb
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: -100
Wrong Answer
time: 0ms
memory: 3664kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
286862654137719264
result:
wrong answer 1st numbers differ - expected: '0', found: '286862654137719264'