QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#596438 | #9434. Italian Cuisine | ucup-team159# | WA | 69ms | 4104kb | C++20 | 7.2kb | 2024-09-28 15:47:18 | 2024-09-28 15:47:18 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < (t); ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define pob pop_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define newline puts("")
#define vc vector
using namespace std;
template<class T> using vv = vc<vc<T>>;
template<class T> using PQ = priority_queue<T,vc<T>,greater<T>>;
using uint = unsigned; using ull = unsigned long long;
using vi = vc<int>; using vvi = vv<int>; using vvvi = vv<vi>;
using ll = long long; using vl = vc<ll>; using vvl = vv<ll>; using vvvl = vv<vl>;
using P = pair<int,int>; using vp = vc<P>; using vvp = vv<P>; using LP = pair<ll,ll>;
int geti(){int x;scanf("%d",&x);return x;}
vi pm(int n, int s=0) { vi a(n); iota(rng(a),s); return a;}
template<class T1,class T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<class T1,class T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<class T>istream& operator>>(istream&i,vc<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<class T>string join(const T&v,const string&d=""){stringstream s;rep(i,sz(v))(i?s<<d:s)<<v[i];return s.str();}
template<class T>ostream& operator<<(ostream&o,const vc<T>&v){if(sz(v))o<<join(v," ");return o;}
template<class T>void vin(vc<T>&a){int n;cin>>n;a=vc<T>(n);cin>>a;}
template<class T>void vin(vv<T>&a){int n,m;cin>>n>>m;a=vv<T>(n,vc<T>(m));cin>>a;}
template<class T1,class T2>void operator--(pair<T1,T2>&a,int){a.fi--;a.se--;}
template<class T1,class T2>void operator++(pair<T1,T2>&a,int){a.fi++;a.se++;}
template<class T>void operator--(vc<T>&a,int){for(T&x:a)x--;}
template<class T>void operator++(vc<T>&a,int){for(T&x:a)x++;}
template<class T1,class T2>void operator+=(vc<T1>&a,T2 b){for(T1&x:a)x+=b;}
template<class T1,class T2>void operator-=(vc<T1>&a,T2 b){for(T1&x:a)x-=b;}
template<class T1,class T2>void operator*=(vc<T1>&a,T2 b){for(T1&x:a)x*=b;}
template<class T1,class T2>void operator/=(vc<T1>&a,T2 b){for(T1&x:a)x/=b;}
template<class T>void operator+=(vc<T>&a,const vc<T>&b){a.insert(a.end(),rng(b));}
template<class T1,class T2>pair<T1,T2>operator+(const pair<T1,T2>&a,const pair<T1,T2>&b){return {a.fi+b.fi,a.se+b.se};}
template<class T1,class T2>pair<T1,T2>operator-(const pair<T1,T2>&a,const pair<T1,T2>&b){return {a.fi-b.fi,a.se-b.se};}
template<class T>pair<T,T>operator*(const pair<T,T>&a,T b){return {a.fi*b,a.se*b};}
template<class T1,class T2>bool mins(T1& x,const T2&y){if(y<x){x=y;return true;}else return false;}
template<class T1,class T2>bool maxs(T1& x,const T2&y){if(x<y){x=y;return true;}else return false;}
template<class T>T min(const vc<T>&a){return *min_element(rng(a));}
template<class T>T max(const vc<T>&a){return *max_element(rng(a));}
template<class Tx,class Ty>Tx dup(Tx x, Ty y){return (x+y-1)/y;}
template<class T>ll suma(const vc<T>&a){ll s=0;for(auto&&x:a)s+=x;return s;}
template<class T>ll suma(const vv<T>&a){ll s=0;for(auto&&x:a)s+=suma(x);return s;}
template<class T>void uni(T&a){sort(rng(a));a.erase(unique(rng(a)),a.end());}
template<class T>void prepend(vc<T>&a,const T&x){a.insert(a.begin(),x);}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return;}
#define yes { puts("Yes"); return;}
#define no { puts("No"); return;}
#define rtn(x) { cout<<(x)<<'\n'; return;} // flush!
#define yn {puts("Yes");}else{puts("No");}
using l3 = __int128_t;
using ul3 = __uint128_t;
std::ostream &operator<<(std::ostream &o, l3 x) {
string s;
bool sg = x < 0;
ul3 ux = sg?-x:x;
do {s += '0'+ux%10; ux /= 10;} while (ux);
if (sg) s += '-';
reverse(rng(s));
return o<<s;
}
// geom integer
struct V {
ll x, y;
V(ll x=0, ll y=0):x(x),y(y){}
V operator+(const V& t) const { return V(x+t.x,y+t.y);}
V operator-(const V& t) const { return V(x-t.x,y-t.y);}
V operator*(ll t) const { return V(x*t,y*t);}
V operator/(ll t) const { return V(x/t,y/t);}
V operator*(const V& t) const { return V(x*t.x-y*t.y,x*t.y+y*t.x);}
V operator/(const V& t) const { return *this*V(t.x,-t.y)/t.norm2();}
V& operator+=(const V& t) { x += t.x; y += t.y; return *this;}
V& operator-=(const V& t) { x -= t.x; y -= t.y; return *this;}
V& operator*=(ll t) { x *= t; y *= t; return *this;}
V& operator/=(ll t) { x /= t; y /= t; return *this;}
V& operator*=(const V& t) { return *this = *this*t;}
V& operator/=(const V& t) { return *this = *this/t;}
ll dot(const V& t) const { return x*t.x + y*t.y;}
ll cross(const V& t) const { return x*t.y - y*t.x;}
ll norm2() const { return x*x + y*y;}
double norm() const { return sqrt(x*x + y*y);}
V rev() const { return V(-x,-y);}
V rotate90() const { return V(-y,x);}
bool operator<(const V& a) const { return x != a.x ? x < a.x : y < a.y;}
bool operator==(const V& a) const { return x == a.x && y == a.y;}
int side() const {
if (!y) return !x ? 0 : (x > 0 ? 1 : 3);
return y > 0 ? 2 : 4;
}
// bool operator<(const V& a) const {
// int s = side(), sa = a.side();
// if (s != sa) return s < sa;
// return cross(a) > 0;
// }
};
istream& operator>>(istream&i,V&a){i>>a.x>>a.y;return i;}
ostream& operator<<(ostream&o,const V&a){o<<a.x<<','<<a.y;return o;}
struct Line {
V s, t;
Line(V s=V(0,0), V t=V(0,0)):s(s),t(t){}
V dir() const { return t-s;}
ll norm2() const { return dir().norm2();}
double norm() const { return dir().norm();}
/* +1: s-t,s-p : ccw
* -1: s-t,s-p : cw
* +2: t-s-p
* -2: s-t-p
* 0: s-p-t */
int ccw(const V& p) const {
if (dir().cross(p-s) > 0) return +1;
if (dir().cross(p-s) < 0) return -1;
if (dir().dot(p-s) < 0) return +2;
if (dir().dot(t-p) < 0) return -2;
return 0;
}
bool touch(const Line& l) const {
int a = ccw(l.s)*ccw(l.t), b = l.ccw(s)*l.ccw(t);
return !a || !b || (a == -1 && b == -1);
}
bool distLP2(const V& p, ll r) const {
ll d = dir().cross(p-s);
return d*d < (l3)r*r*norm2();
}
};
using Poly = vector<V>;
inline V pnxt(Poly& p, int i) { return p[(i+1)%sz(p)];}
inline V ppre(Poly& p, int i) { return p[(i-1+sz(p))%sz(p)];}
inline Line pline(Poly& p, int i) { return Line(p[i],pnxt(p,i));}
// geom
struct Solver {
void solve() {
int n;
scanf("%d",&n);
V o; int r;
cin>>o>>r;
vc<V> ps(n);
cin>>ps;
int j = 1;
ll now = 0, ans = 0;
rep(i,n) {
while (1) {
int nj = (j+1)%n;
Line l(ps[i],ps[nj]);
if (l.ccw(o) != 1) break;
if (l.distLP2(o,r)) break;
now += abs((ps[j]-ps[i]).cross(ps[nj]-ps[i]));
j = nj;
}
maxs(ans,now);
now -= abs((ps[i]-ps[j]).cross(pnxt(ps,i)-ps[j]));
}
printf("%lld\n",ans);
}
};
int main() {
// cin.tie(nullptr); ios::sync_with_stdio(false);
int ts = 1;
scanf("%d",&ts);
rep1(ti,ts) {
Solver solver;
solver.solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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: 4104kb
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: 0
Accepted
time: 35ms
memory: 3808kb
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 3086 2539 668 3535 7421 4883 5711 5624 1034 2479 3920 4372 2044 4996 5070 2251 4382 4175 1489 1154 3231 4038 1631 5086 14444 1692 6066 687 1512 4849 5456 2757 8341 8557 8235 1013 5203 10853 6042 6300 4480 2303 2728 1739 2187 3385 4266 6322 909 4334 1518 948 5036 1449 2376 3180 4810 1443 1786 47...
result:
ok 6666 numbers
Test #4:
score: -100
Wrong Answer
time: 69ms
memory: 3804kb
input:
6660 19 -689502500 -712344644 121094647 -534017213 -493851833 -578925616 -506634533 -663335128 -540066520 -748890119 -585225068 -847722967 -641694086 -916653030 -716279342 -956235261 -766049951 -1000000000 -836145979 -963288744 -923225928 -948140134 -944751289 -920681768 -972760883 -872492254 -10000...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st numbers differ - expected: '117285633945667137', found: '0'