QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596405#9434. Italian Cuisineucup-team159#WA 44ms4096kbC++208.4kb2024-09-28 15:43:042024-09-28 15:43:05

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 15:43:05]
  • 评测
  • 测评结果:WA
  • 用时:44ms
  • 内存:4096kb
  • [2024-09-28 15:43:04]
  • 提交

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));}
Poly conv(Poly a) { // cw
  int n = sz(a);
  if (n <= 2) return a;
  sort(rng(a));
  Poly res(n*2);
  int k = 0;
  for (int i = 0; i < n; ++i){
    while (k > 1 && Line(res[k-1],res[k-2]).ccw(a[i]) != 1) --k; // <= -1 ok line
    res[k++] = a[i];
  }
  int pre = k;
  for (int i = n - 2; 0 <= i; --i){
    while (k > pre && Line(res[k-1],res[k-2]).ccw(a[i]) != 1) --k; // <= -1 ok line
    res[k++] = a[i];
  }
  res.resize(k-1);
  return res;
}
ll area2(Poly& a) {
  ll res = 0;
  rep(i,sz(a)-2){
    res += abs(V(a[i+1]-a[0]).cross(V(a[i+2]-a[0])));
  }
  return res; // area*2
}
// 1: IN, 0: ON, -1: OUT
int side(const Poly& p, V a) { // p: ccw
  int c1 = Line(p[0],p[1]).ccw(a);
  int c2 = Line(p[0],p.back()).ccw(a);
  if (c1 == 0 || c2 == 0) return 0;
  if (c1 == -1 || c2 == 1) return -1;
  int l = 1, r = sz(p)-1;
  while (l+1<r) {
    int c = (l+r)>>1;
    if (Line(p[0],p[c]).ccw(a) == 1) l = c; else r = c;
  }
  return Line(p[l],p[r]).ccw(a);
}

struct Circle {
  V o; ll r;
  Circle(V o=V(0,0), ll r=0):o(o),r(r){}
  bool in(V p) { return (p-o).norm2() < r*r;}
  bool touch(Circle c) { return (c.o-o).norm2() < (c.r+r)*(c.r+r);}
};

// 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-ps[i]) != 1) break;
        if (l.distLP2(o,r)) break;
        now += abs((ps[j]-ps[i]).cross(ps[nj]-ps[i]));
        j = nj;
      }
      maxs(ans,now);

      if ((i+1)%n == j) j = (j+1)%n;
      else {
        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: 4096kb

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: 3832kb

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: 44ms
memory: 3772kb

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
1674
1575
646
3535
5777
4883
10757
4748
892
1642
3777
2326
2044
4996
5070
1167
4382
4175
1007
1154
3231
4019
1631
5086
25218
1692
6066
687
1512
3580
5097
2757
4700
8557
8235
1877
11759
17178
12398
4553
4480
2038
2728
773
1917
3385
4039
6322
776
3907
634
844
13832
1449
2291
2530
4810
1443
936
39...

result:

wrong answer 2nd numbers differ - expected: '3086', found: '1674'