QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#626243 | #9434. Italian Cuisine | Dung1604 | WA | 14ms | 3600kb | C++17 | 3.5kb | 2024-10-10 01:03:21 | 2024-10-10 01:03:22 |
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 = i+2; 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) {
break;
}
else {
int type = locate(first, last, { x, y });
ll ret = 0;
if (type == 1) {
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));
}
ans = max(ans, ret);
}
else {
break;
}
}
}
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
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: 3600kb
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: 14ms
memory: 3540kb
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:
5093 2862 1753 668 3535 7421 4883 4842 4552 1034 1642 3777 4372 1774 4996 5070 2251 3225 4175 1489 1104 3231 4038 1631 5086 14444 1692 6066 687 1512 3375 5097 2757 6599 8073 7008 744 5076 9576 5655 5412 4480 2303 2728 773 2187 3385 4266 4936 901 4334 1518 948 5036 1449 2376 3180 4810 1443 1478 4783 ...
result:
wrong answer 2nd numbers differ - expected: '3086', found: '2862'