QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601458#9434. Italian Cuisinekevinshan#WA 14ms3868kbC++233.6kb2024-09-30 00:23:512024-09-30 00:23:53

Judging History

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

  • [2024-09-30 00:23:53]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3868kb
  • [2024-09-30 00:23:51]
  • 提交

answer

#pragma GCC optimize("Ofast,O3,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define double long double
#define all(x) x.begin(), x.end()
#define pb push_back
#define f first
#define s second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;


template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};


template<class P> 
ll prod(const P& a, const P& b, const P& p) {
    return (b-a).cross(p-a);
}
template<class P> 
ll prod2(const P& a, const P& b, const P& p) {
    return prod(a,b,p) * prod(a,b,p);
}

bool comp(ll prod, ll r, ll d2) {
    return (__int128)prod * (__int128)prod >= (__int128)r * (__int128)r * (__int128)d2; 
}

// // +
// template<class P>
// double lineDist(const P& a, const P& b, const P& p) {
// 	return (double)(b-a).cross(p-a)/(b-a).dist();
// }

// template<class T>
// T polygonArea2(vector<Point<T>>& v) {
// 	T a = v.back().cross(v[0]);
// 	rep(i,0,sz(v)-1) a += v[i].cross(v[i+1]);
// 	return a;
// }

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int t; cin>>t;
    while(t--){
        int n;
        cin>>n;
        ll x_c, y_c, R;
        cin>>x_c>>y_c>>R;
        Point<ll> center = Point(x_c, y_c);
        vector<Point<ll>> polygon;
        ll x, y;
        for(int i=0; i<n; i++) {
            cin>>x>>y;
            polygon.emplace_back(x,y);
        }



        ll area = 0;
        int r = 0;
        ll ans = 0;

        for(int l=0; l<n; l++) {
            if(r < l) {
                r = l;
                area = 0;
            }
            while((r+1)%n != l && prod(polygon[l],polygon[(r+1)%n],center) >= 0 &&
                    comp(prod(polygon[l],polygon[(r+1)%n],center), R, (polygon[l]-polygon[(r+1)%n]).dist2())) {
                
                area += polygon[r].cross(polygon[(r+1)%n]);
                r = (r+1) % n;
            }
            // cout<<l<<"|"<<r<<"\n";
            if(r != (l+1) % 2)
                ans = max(ans, area + polygon[r].cross(polygon[l]));
            // cout<<area + polygon[r].cross(polygon[l])<<"\n";
            area -= polygon[l].cross(polygon[(l+1)%n]);
        }
        cout<<ans<<"\n";
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

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

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

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
1679
4996
5070
2251
4382
4175
1489
1154
3231
4038
1631
5086
14444
1692
6066
687
1512
4849
5456
2757
8341
8353
8235
1013
5203
10853
6042
6300
4480
2303
2728
1739
2187
3385
4266
5512
909
4334
1518
948
5036
1449
2376
3180
4810
1443
1478
47...

result:

wrong answer 14th numbers differ - expected: '2044', found: '1679'