QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#645065 | #9434. Italian Cuisine | Djangle162857 | WA | 52ms | 3760kb | C++14 | 4.6kb | 2024-10-16 16:45:30 | 2024-10-16 16:45:30 |
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++) {
if (i != n - 1)
ed = max(ed, (i + 1) % n);
else {
if (ed == n - 1)
ed = 1;
}
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 -= 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: 3720kb
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: 3752kb
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: 52ms
memory: 3760kb
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:
14676 2862 3649 668 4978 12249 5974 27821 15618 1034 3636 7753 9147 2898 4996 5838 6592 10402 5438 1489 1164 6104 7376 3361 10703 57088 1692 24445 687 1512 18564 10662 4209 25848 23523 26063 1651 27217 39215 30682 24912 7703 2303 2728 2460 2349 3385 6723 22233 1180 4334 1518 948 14300 1450 3585 3180...
result:
wrong answer 1st numbers differ - expected: '5093', found: '14676'