QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595539#9434. Italian Cuisineucup-team4479#WA 48ms7048kbC++232.5kb2024-09-28 13:56:402024-09-28 13:56:41

Judging History

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

  • [2024-09-28 13:56:41]
  • 评测
  • 测评结果:WA
  • 用时:48ms
  • 内存:7048kb
  • [2024-09-28 13:56:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=100005;
const long double eps=1e-6;
int n;
struct Point
{
    long double x,y;
    Point(long double _x=0,long double _y=0):x(_x),y(_y){}
    friend Point operator+(const Point &a,const Point &b)
    {
        return Point(a.x+b.x,a.y+b.y);
    }
    friend Point operator-(const Point &a,const Point &b)
    {
        return Point(a.x-b.x,a.y-b.y);
    }
    friend bool operator==(const Point &a,const Point &b)
    {
        return abs(a.x-b.x)<=eps&&abs(a.y-b.y)<=eps;
    }
    Point operator*(const long double &v)const
    {
        return Point(x*v,y*v);
    }
    Point operator/(const long double &v)const
    {
        return Point(x/v,y/v);
    }
    long double length()const
    {
        return sqrtl((long long)x*x+(long long)y*y);
    }
    Point unit()const
    {
        return *this/length();
    }
    friend long double dot(const Point &a,const Point &b)
    {
        return a.x*b.x+a.y*b.y;
    }
    friend long double cross(const Point &a,const Point &b)
    {
        return a.x*b.y-a.y*b.x;
    }
}p[N];
long double distance(const Point &x,const Point &y)
{
    return (x-y).length();
}
struct Line
{
    Point a,b;
    Line(const Point &_a,const Point &_b):a(_a),b(_b){}
    Point projection(const Point &p)const
    {
        return a+(b-a).unit()*(dot(p-a,b-a)/(b-a).length());
    }
};
void solve()
{
    cin>>n;
    Point o;
    int r;
    cin>>o.x>>o.y>>r;
    for(int i=1;i<=n;i++)
        cin>>p[i].x>>p[i].y;
    long double ans=0;
    long double sum=0;
    for(int i=1,j=1;i<=n;i++)
    {
        while(cross(p[j]-p[i],o-p[i])>=-eps&&(p[i]==p[j]||distance(o,Line(p[i],p[j]).projection(o))>=r-eps)) sum+=cross(p[j],p[j%n+1]),j=j%n+1;
        int lstj=j-1;
        if(lstj==0) lstj=n;
        ans=max(ans,sum-cross(p[lstj],p[j])+cross(p[lstj],p[i]));
        sum-=cross(p[i],p[i%n+1]);
    }
    reverse(p+1,p+n+1);
    sum=0;
    for(int i=1,j=1;i<=n;i++)
    {
        while(cross(p[j]-p[i],o-p[i])<=eps&&(p[i]==p[j]||distance(o,Line(p[i],p[j]).projection(o))>=r-eps)) sum+=-cross(p[j],p[j%n+1]),j=j%n+1;
        int lstj=j-1;
        if(lstj==0) lstj=n;
        ans=max(ans,sum+cross(p[lstj],p[j])-cross(p[lstj],p[i]));
        sum-=-cross(p[i],p[i%n+1]);
    }
    cout<<fixed<<setprecision(0)<<ans<<"\n";
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int T;
    cin>>T;
    while(T--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 7032kb

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: 2ms
memory: 7048kb

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: 48ms
memory: 6920kb

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
1753
668
3535
7421
4883
5711
4874
1034
2479
3920
3690
2044
4996
5070
2251
4382
4175
1489
1154
3231
4038
1631
5086
14444
1692
6066
687
1512
4488
5456
2757
8341
8557
8235
1013
5076
10853
6042
5412
4350
2303
2728
1739
2187
3385
4266
6322
909
4334
1518
948
5036
1449
2376
3129
4810
1443
1786
47...

result:

wrong answer 3rd numbers differ - expected: '2539', found: '1753'