QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#609222#9434. Italian CuisineRosmontispesWA 0ms3816kbC++202.8kb2024-10-04 11:18:262024-10-04 11:18:29

Judging History

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

  • [2024-10-04 11:18:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2024-10-04 11:18:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct Point{
    long long x,y;
    Point(long long a = 0,long long b = 0){x = a,y = b;}
};
int sgn(long long x){
    if(x == 0)
        return 0;
    return x > 0?1:-1;
}
Point operator - (Point a,Point b){
    return Point(a.x - b.x,a.y - b.y);
}
long long Dot(Point a,Point b){
    return a.x * b.x + a.y * b.y;
}
long long Cross(Point a,Point b){
    return a.x*b.y - a.y*b.x;
}
long long Cross(Point sp,Point ep,Point op){
    return (sp.x - op.x) * (ep.y - op.y) - (ep.x - op.x) * (sp.y - op.y);
}

long long dis(Point a,Point b){
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
int judge(Point A,Point B,Point C,long long r){
    if(dis(A,B) == 0)
        return dis(B,C) >= r * r;
    if(Dot(B - A,C - A) < 0)
        return dis(A,C) >= r * r;
    if(Dot(A - B,C - B) < 0)
        return dis(B,C) >= r * r;
    return Cross(B - A,C - A) * Cross(B - A,C - A) >= r * r * dis(B,A);
}

void solve(){
    int n; 
    cin>>n;
    long long cx,cy,r;
    cin>>cx>>cy>>r;
    Point cir(cx,cy);
    vector<Point>poi(n);
    for(int i = 0;i < n;i ++){
        long long x,y;
        cin>>x>>y;
        poi[i] = Point(x,y);
    }
    int j = 0;
    long long S = 0;
    long long ans = 0;
    for(int st = 0;st < n;st ++){
        if(j == st){
            j = j + 1 >= n?(j + 1 - n):j + 1;
            S = Cross(poi[st],poi[j]);
        }
        int nex = j + 1 >= n?(j + 1 - n):j + 1;
        while(j != st){
            if(sgn(Cross(poi[j],cir,poi[st])) * sgn(Cross(poi[nex],cir,poi[st])) <= 0)
                break;
            if(!judge(poi[st],poi[nex],cir,r))
                break;
            S += Cross(poi[j],poi[nex]);
            j = nex;
            nex = j + 1 >= n?(j + 1 - n):j + 1;
        }
        ans = max(ans,S + Cross(poi[j],poi[st]));
        nex = st + 1 >= n?(st + 1 - n):st + 1;
        S -= Cross(poi[st],poi[nex]);
    }
    j = n - 1;
    for(int st = n - 1;st >= 0;st --){
        if(j == st){
            j = j - 1 < 0?(j - 1 + n):j - 1;
            S = Cross(poi[st],poi[j]);
        }
        int nex = j - 1 < 0?(j - 1 + n):j - 1;
        while(j != st){
            if(Cross(poi[j],cir,poi[st]) * Cross(poi[nex],cir,poi[st]) <= 0)
                break;
            if(!judge(poi[st],poi[nex],cir,r))
                break;
            S += Cross(poi[j],poi[nex]);
            j = nex;
            nex = j - 1 < 0?(j - 1 + n):j - 1;
        }
        ans = max(ans,-(S + Cross(poi[j],poi[st])));
        nex = st - 1 < 0?(st - 1 + n):st - 1;
        S -= Cross(poi[st],poi[nex]);
    }
    cout<<ans<<"\n";
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T --)
        solve();
}

详细

Test #1:

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

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

input:

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

output:

688265363857191648

result:

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