QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601444#9434. Italian Cuisinekevinshan#WA 0ms3844kbC++233.4kb2024-09-29 23:59:552024-09-29 23:59:55

Judging History

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

  • [2024-09-29 23:59:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-09-29 23:59:55]
  • 提交

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);
}


// // +
// 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 &&
                    prod2(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";
    }
}


详细

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3844kb

input:

1
6
0 0 499999993
197878055 -535013568
696616963 -535013568
696616963 40162440
696616963 499999993
-499999993 499999993
-499999993 -535013568

output:

550249412925348668

result:

wrong answer 1st numbers differ - expected: '0', found: '550249412925348668'