QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676288 | #9434. Italian Cuisine | ucup-team5367# | WA | 8ms | 36136kb | C++23 | 3.4kb | 2024-10-25 20:57:40 | 2024-10-25 20:57:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
using ld = long double;
const int md = 998244353;
const int maxn = 1e6+10;
const ld DINF = 1e18;
const ld pi = acosl(-1.0);
const ld eps = 1e-9;
#define sq(x) ((x)*(x))
bool eq(ld a, ld b) {
return abs(a - b) <= eps;
}
struct pt { // ponto
ld x, y;
pt(ld x_ = 0, ld y_ = 0) : x(x_), y(y_) {}
bool operator < (const pt p) const {
if (!eq(x, p.x)) return x < p.x;
if (!eq(y, p.y)) return y < p.y;
return 0;
}
bool operator == (const pt p) const {
return eq(x, p.x) and eq(y, p.y);
}
pt operator + (const pt p) const { return pt(x+p.x, y+p.y); }
pt operator - (const pt p) const { return pt(x-p.x, y-p.y); }
pt operator * (const ld c) const { return pt(x*c , y*c ); }
pt operator / (const ld c) const { return pt(x/c , y/c ); }
ld operator * (const pt p) const { return x*p.x + y*p.y; }
ld operator ^ (const pt p) const { return x*p.y - y*p.x; }
friend istream& operator >> (istream& in, pt& p) {
return in >> p.x >> p.y;
}
};
struct line { // reta
pt p, q;
line() {}
line(pt p_, pt q_) : p(p_), q(q_) {}
friend istream& operator >> (istream& in, line& r) {
return in >> r.p >> r.q;
}
};
ld sarea(pt p, pt q, pt r) { // area com sinal
return ((q-p)^(r-q))/2;
}
ld dist(pt p, pt q) { // distancia
return hypot(p.y - q.y, p.x - q.x);
}
ld disttoline(pt p, line r) { // distancia do ponto a reta
return 2 * abs(sarea(p, r.p, r.q)) / dist(r.p, r.q);
}
bool ccw(pt p, pt q, pt r) { // se p, q, r sao ccw
return sarea(p, q, r) > eps;
}
int n;
pt c;
int raio;
pt p[maxn];
ld pref_area[maxn];
bool circle_on_left(int l, int r)
{
if(r > n) r -= n;
if(!ccw(p[l], p[r], c))
return false;
bool ret = disttoline(c, line(p[l], p[r])) >= raio - eps;
// cout<< l<< " "<< r<< " "<< ret<< "\n";
// if(l == 1 && r == 3)
// {
// cout<< "oi\n";
// cout<< ccw(p[l], p[r], c)<< "\n";
// cout<< disttoline(c, line(p[l], p[r]))<< " "<< raio<< "\n";
// cout<< ret<< "\n";
// }
return ret;
}
ld interval_polygon_area(int l, int r)
{
if(r > n) r -= n;
if(r > l)
{
return pref_area[r] - pref_area[l] - abs(sarea(p[1], p[l], p[r]));
}
else
{
return pref_area[n] - ( pref_area[l] - pref_area[r] - abs(sarea(p[1], p[r], p[l])) );
}
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int T; cin>> T;
while(T--)
{
// cout<< "caso "<< T<< "\n";
cin>> n;
cin>> c.x>> c.y>> raio;
for(int i=1; i<=n; i++)
cin>> p[i].x>> p[i].y;
pref_area[1] = pref_area[2] = 0;
for(int i=3; i<=n; i++)
{
pref_area[i] = pref_area[i-1] + abs(sarea(p[1], p[i-1], p[i]));
}
ld tot_area = pref_area[n];
ld ans = 0;
for(int l=1, r=2; l<=n; l++)
{
if(r <= l) r = l+1;
while(r+1 != l+n && circle_on_left(l, r+1))
r++;
// cout<< l<< " foi ate "<< r<< "\n";
ans = max(ans, interval_polygon_area(l, r));
}
cout<< setprecision(15)<< fixed;
// for(int i=1; i<=n; i++)
// {
// cout<< i<< " "<< pref_area[i]<< "\n";
// }
cout<< ll(round(2 * ans))<< "\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 35416kb
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: 8ms
memory: 36136kb
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'