QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#797939#9434. Italian Cuisineq1w2e3r4#WA 0ms3600kbC++142.4kb2024-12-03 21:26:362024-12-03 21:26:40

Judging History

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

  • [2024-12-03 21:26:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-12-03 21:26:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
 
int T,n,xc,yc,r;
struct P{
    int x,y;
    P(int x=0, int y=0): x(x),y(y){};
};

const double eps = 1e-8;
inline P operator+ (P A, P B){ return P(A.x + B.x, A.y + B.y);}
inline P operator- (P A, P B){ return P(A.x - B.x, A.y - B.y);}
inline bool operator== (P a, P b){ return a.x == b.x && a.y == b.y;}
inline int Cross(P a, P b){ return a.x * b.y - a.y * b.x;}
inline int Dot(P a, P b){ return a.x * b.x + a.y * b.y;}
inline double Length(P a){
    return sqrt(Dot(a, a));
}
inline int dcmp(double x){
    if(fabs(x) < eps) return 0;
    return x < 0? -1: 1;
}

inline double DistanceToLine(P p, P a, P b){
    P v1 = b - a, v2 = p - a;
    return Cross(v1, v2) / Length(v1);
}

inline int Area2(P a, P b , P c){
    return abs(Cross(b - a, c - a));
}

signed main(){
    cin >> T;
    while(T--){
        cin >> n;
        cin >> xc >> yc >> r;
        P c = {xc, yc};
        vector<P> v(n);
        for(int i=0;i<n;i++){
            cin >> v[i].x >> v[i].y;
        }

        int ans = 0;
        int area = 0;
        for(int i=0,j=1; i<n; i++){
            if(i == j) j = (j+1) % n;
            while(1){
                // cout << i << " " << j << endl;
                int nxt = (j+1) % n;
                double d = DistanceToLine(c, v[i], v[nxt]);
                if(dcmp(d-r) >= 0){
                    area += Area2(v[i], v[j], v[nxt]);
                    j = nxt;
                }
                else break; 
            }
            ans = max(area, ans);
            cout << i << " " << j << " " << area << " " << ans << endl; 
            area -= Area2(v[i], v[(i+1)%n], v[j]);
        }

        // area = 0;
        // for(int i=0,j=n-1; i<n;i++){
        //     if(i == j) j = (j+n-1) % n;
        //     while(1){
        //         int nxt = (j+n-1) % n;
        //         double d = -DistanceToLine(c, v[i], v[nxt]);
        //         if(dcmp(d-r) >= 0){
        //             area += Area2(v[i], v[j], v[nxt]);
        //             j = nxt;
        //         }
        //         else break; 
        //     }
        //     ans = max(area, ans);
        //     // cout << i << " " << j << " " << area << " " << ans << endl; 
        //     area -= Area2(v[i], v[(i+1)%n], v[j]);
        // }
        cout << ans << endl;
    }
     
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

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:

0 2 0 0
1 2 0 0
2 4 5 5
3 4 0 5
4 0 0 5
5
0 3 24 24
1 3 12 24
2 4 6 24
3 4 0 24
4 5 0 24
5 2 24 24
24
0 1 0 0
1 2 0 0
2 3 0 0
3 0 0 0
0

result:

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