QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#598521 | #9434. Italian Cuisine | ucup-team4967# | WA | 0ms | 3756kb | C++17 | 2.1kb | 2024-09-28 22:17:33 | 2024-09-28 22:17:33 |
Judging History
answer
#include "bits/stdc++.h"
//#include <atcoder/all>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)998244353
#define P pair<ll, ll>
ll area(P a, P b, P c){
b.first -= a.first;
c.first -= a.first;
b.second -= a.second;
c.second -= a.second;
return abs(b.first * c.second - b.second * c.first);
}
ll norm2(P a, P b){
return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}
bool intersect_seg(P a, P b, ll xc, ll yc, ll r){
if(norm2(a, P(xc, yc)) <= r * r or norm2(b, P(xc, yc)) <= r * r) return true;
__uint128_t x = area(a, b, P(xc, yc)), h = r, L = norm2(a, b);
x = x * x / (r * r);
if(x * x / (r * r) >= L) return false;
__uint128_t A = norm2(a, b), B = norm2(a, P(xc, yc)), C = norm2(b, P(xc, yc));
if((A + B - C) * (A + B - C) - 4 * A * B <= 0)return false;
if((A + C - B) * (A + C - B) - 4 * A * C <= 0)return false;
return true;
}
bool is_in(P a, P b, P c, ll xc, ll yc, ll r){
if(area(a, b, P(xc, yc)) + area(c, b, P(xc, yc)) + area(a, c, P(xc, yc)) == area(a, b, c)) return true;
if(intersect_seg(a, b, xc, yc, r) or intersect_seg(a, c, xc, yc, r) or intersect_seg(c, b, xc, yc, r)) return true;
return false;
}
ll solve(ll n) {
ll xc, yc, R;
cin >> xc >> yc >> R;
vector<P> v;
REP(i, n){
ll a, b;
cin >> a >> b;
v.push_back(P( a, b));
}
ll r = 1, now = 0, ans = 0;
REP(l, n){
if(l == r) r = (r + 1) % n;
while(!is_in(v[l], v[r], v[(r + 1) % n], xc, yc, R)){
now += area(v[l], v[r], v[(r + 1) % n]);
r = (r + 1) % n;
ans = max(ans, now);
}
now -= area(v[l], v[(l + 1) % n], v[r]);
}
return ans;
}
int main() {
ll tt;
cin >> tt;
REP(ttt, tt){
ll n;
cin >> n;
cout << solve(n) << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 3756kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
516201533178331388
result:
wrong answer 1st numbers differ - expected: '0', found: '516201533178331388'