QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#626238 | #9434. Italian Cuisine | Dung1604 | WA | 1ms | 3608kb | C++17 | 3.5kb | 2024-10-10 00:53:33 | 2024-10-10 00:53:34 |
Judging History
answer
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <tuple>
#include <iomanip>
#include <map>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <unordered_map>
#define ll long long
#define inf 10000000000007
#define mod 1000000007
using namespace std;
const int BLOCK = 450;
ll fastpow(ll n, ll x) {
if (x == 0) {
return 1;
}
else {
ll ret = fastpow(n, x / 2);
ret = ((ret % mod) * (ret % mod)) % mod;
if (x % 2 == 0) {
return ret;
}
else {
return ((ret) * (n)) % mod;
}
}
}
ll gcd(ll a, ll b) {
if (a == 0) {
return b;
}
if (b == 0) {
return a;
}
else {
return gcd(b, a % b);
}
}
ll lcm(ll a, ll b) {
ll val = (a % mod * b % mod) % mod;
val = (val * fastpow(gcd(a, b), mod - 2)) % mod;
return val;
}
int Logk(ll n, ll k) {
if (k == 1) {
return 1;
}
if (n == 0) {
return 0;
}
int count = -1;
while (n > 0) {
count++;
n /= k;
}
return count;
}
struct Dsu {
vector<int> par;
void init(int n) {
par.resize(n + 5, 0);
for (int i = 1; i <= n; i++) par[i] = i;
}
int find(int u) {
if (par[u] == u) return u;
return par[u] = find(par[u]);
}
bool join(int u, int v) {
u = find(u); v = find(v);
if (u == v) return false;
par[v] = u;
return true;
}
} dsu;
struct point {
ll x, y;
};
struct line {
ll a, b, c;
};
struct vecto {
ll x, y;
};
line create(point point1, point point2) {
line ret;
ret.a = point2.y - point1.y;
ret.b = point1.x - point2.x;
ret.c = -(ret.a * point1.x + ret.b * point1.y);
return ret;
}
pair<ll, ll> dif(line line1, point point1) {
ll tu = abs(line1.a * point1.x + line1.b * point1.y + line1.c);
tu *= tu;
ll mau = line1.a * line1.a + line1.b * line1.b;
return { tu, mau };
}
int locate(point A, point B, point C) {
vecto AB = { B.x - A.x, B.y - A.y };
vecto AC = { C.x - A.x, C.y - A.y };
if (AB.x * AC.y - AB.y * AC.x < 0) {
return 2;
//RIGHT
}
else if (AB.x * AC.y - AB.y * AC.x > 0) {
return 1;
}
else {
return 0;
}
}
void solve() {
int n;
cin >> n;
ll x, y, r;
cin >> x >> y >> r;
vector<point> a;
vector<ll> prefix(n+1);
vector<ll> res(n, -1);
for (int i = 0; i < n; i++) {
ll x, y;
cin >> x >> y;
a.push_back({ x, y });
}
a.push_back(a[0]);
prefix[0] = 0;
for (int i = 1; i <= n; i++) {
prefix[i] = prefix[i-1] + (a[i-1].x * a[i].y - a[i-1].y * a[i].x);
}
ll ans = 0;
for (int i = 0; i < n; i++) {
point first = a[i];
for (int j = 0; j < n; j++) {
point last = a[j];
pair<ll, ll> dis = dif(create(first, last), { x, y });
if (abs(i - j) < 2) {
continue;
}
if (dis.first <= r * r * dis.second) {
continue;
}
else {
int type = locate(first, last, { x, y });
ll ret = 0;
if (i < j) {
ret = prefix[j] - prefix[i] + (a[j].x * a[i].y - a[j].y * a[i].x);
}
else {
ret = prefix[n] - (prefix[i] - prefix[j] + (a[i].x * a[j].y - a[i].y * a[j].x));
}
if (type == 1) {
ans = max(ans, ret);
}
else {
ans = max(ans, prefix[n] - ret);
}
}
}
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3608kb
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: 3548kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
688265363857191648
result:
wrong answer 1st numbers differ - expected: '0', found: '688265363857191648'