QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#425353 | #784. 旋转卡壳 | yzy1 | 0 | 1ms | 3912kb | C++23 | 3.0kb | 2024-05-30 09:12:15 | 2024-05-30 09:12:16 |
Judging History
answer
#include <bits/stdc++.h>
#if defined(LOCAL)
#define DBG_MACRO_NO_WARNING
#include <dbg.hpp>
#else
#define dbg(x...) (0)
#endif
using namespace std;
using ll = long long;
// #define int ll
#define rep(i, f, t) for (int i = (f), ed##i = (t); i <= ed##i; ++i)
#define re(i, t) rep (i, 1, t)
#define per(i, t, f) for (int i = (t), ed##i = (f); i >= ed##i; --i)
#define ste(i, f, t, s) for (int i = (f), ed##i = (t); i <= ed##i; i += s)
#define nxt(i, f, g) for (int i = g.h[f]; i; i = g.e[i].n)
#define umod(x) ((x) >= mo && ((x) -= mo))
#define dmod(x) ((x) < 0 && ((x) += mo))
#define y1 y1__
#define fio(x) (freopen(x ".in", "r", stdin), freopen(x ".out", "w", stdout))
template <class T, class E>
__attribute__((always_inline)) inline void up(T &x, E &&y) {
if (x < y) x = y;
}
template <class T, class E>
__attribute__((always_inline)) inline void down(T &x, E &&y) {
if (y < x) x = y;
}
struct P {
double x = 0, y = 0;
inline int Q() const { return (y < 0) << 1 | ((x < 0) ^ (y < 0)); }
inline double Norm2() const { return x * x + y * y; }
};
inline P operator+(P x, P y) { return {x.x + y.x, x.y + y.y}; }
inline P operator*(P x, double y) { return {x.x * y, x.y * y}; }
inline P operator-(P x, P y) { return {x.x - y.x, x.y - y.y}; }
inline double operator*(P x, P y) { return x.x * y.x + x.y * y.y; }
inline double operator^(P x, P y) { return x.x * y.y - x.y * y.x; }
inline vector<P> Bag(vector<P> a) {
sort(a.begin(), a.end(), [](auto x, auto y) { return x.x != y.x ? x.x < y.x : x.y < y.y; });
vector<P> bag;
rep (i, 0, a.size() - 1) {
while (bag.size() >= 2 && ((bag.back() - bag[bag.size() - 2]) ^ (a[i] - bag.back())) <= 0)
bag.pop_back();
bag.push_back(a[i]);
}
// dbg(bag);
int tmp = bag.size();
per (i, a.size() - 2, 0) {
while ((int)bag.size() > tmp && ((bag.back() - bag[bag.size() - 2]) ^ (a[i] - bag.back())) <= 0)
bag.pop_back();
bag.push_back(a[i]);
// dbg(bag);
}
bag.pop_back();
return bag;
}
int n;
vector<P> a;
inline P Rot(P x) { return {-x.y, x.x}; }
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
re (i, n) {
double x, y;
cin >> x >> y;
a.push_back({x, y});
}
a = Bag(a);
n = a.size();
// rep (i, 0, n - 1) cerr << a[i].x << ' ' << a[i].y << '\n';
int u = 2;
double ans = -1e18;
rep (i, 0, n - 1) {
auto v1 = a[(i + 1) % n] - a[i];
auto dw = v1 * (1. / sqrt(v1.Norm2()));
auto rdw = Rot(dw);
auto Calc1 = [&](int x) {
x %= n;
return (a[x] - a[i]) * rdw;
};
auto Calc2 = [&](int x) {
x %= n;
return max((a[x] - a[i]).Norm2(), (a[x] - a[(i + 1) % n]).Norm2());
};
while (Calc1(u + 1) > Calc1(u)) ++u;
double res = Calc2(u);
// dbg(u, res);
// if (i == n - 1) {
// dbg(Calc2(3));
// dbg(Calc2(4));
// dbg(Calc2(5));
// }
up(ans, res);
}
// dbg(ans);
cout << llround(ans) << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3912kb
input:
1000 0 0 -997615 -8573 -1988394 -28911 -2726572 -44296 -3491635 -60392 -4419752 -82814 -5298550 -105946 -5723430 -118453 -6608257 -147267 -7034966 -161982 -7563964 -181682 -8507871 -222865 -9499799 -271846 -10090186 -303547 -10400262 -322989 -10614073 -339725 -11081438 -378596 -11791568 -439127 -127...
output:
75262009380251984
result:
wrong answer 1st numbers differ - expected: '274339223.1895614', found: '75262009380251984.0000000', error = '274339222.1895615'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%