QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#679693#9434. Italian CuisinererebornzhouWA 63ms3796kbC++204.1kb2024-10-26 18:09:102024-10-26 18:09:12

Judging History

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

  • [2024-10-26 18:09:12]
  • 评测
  • 测评结果:WA
  • 用时:63ms
  • 内存:3796kb
  • [2024-10-26 18:09:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
typedef pair<int,int> pii;

const int N=3e5+10;

const double pi = acos(-1.0); //圆周率,精确到15位小数
const double eps = 1e-8; //浮点数偏差值

int sgn(double x){  //判断与0的大小关系
    if(fabs(x)<eps) return 0;
    return x<0?-1:1;
}

int dcmp(double x,double y){  //判断两个浮点数的大小关系
    if(fabs(x-y)<eps) return 0;
    else return x<y?-1:1;
}

struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point(Point a,Point b){  //向量
        x=b.x-a.x, y=b.y-a.y;
    }

    Point operator + (Point B){ return Point(x+B.x,y+B.y); }
    Point operator - (Point B){ return Point(x-B.x,y-B.y); }
    Point operator * (double k){ return Point(x*k,y*k); } //向量与实数的乘法
    Point operator / (double k){ return Point(x/k,y/k); } //向量与实数的除法
    bool operator == (Point B){ return sgn(x-B.x)==0 && sgn(y-B.y==0); } //两个向量判等
};

// 以下向量相关

typedef Point Vector; //用点的数据结构来表示向量

double Cross(Vector A,Vector B){ return A.x*B.y - A.y*B.x; } //向量叉积,有正负

//以下线相关
struct Line{
    Point p1,p2;  //直线上两点
    Line(){}
    Line(Point p1,Point p2):p1(p1),p2(p2){}
    Line(Point p,double angle){  //根据一个点和倾斜角确定直线,0<=angle<pi
        p1=p;
        if(sgn(angle-pi/2)==0) { p2 = (p1 + Point(0,1));} //tan(pi/2)不存在
        else { p2 = (p1 + Point(1,tan(angle)));}
    }
    Line(double a,double b,double c){  //ax+by+c=0
        if(sgn(a)==0){
            p1 = Point(0,-c/b);
            p2 = Point(1,-c/b);
        }
        else if(sgn(b)==0){
            p1 = Point(-c/b,0);
            p2 = Point(-c/b,1);
        }
        else{
            p1 = Point(0,-c/b);
            p2 = Point(1,(-c-a)/b);
        }
    }
};

double Distance_point(Point A,Point B){ return hypot(A.x-B.x,A.y-B.y); }  //两点之间的距离

double Dis_point_line(Point p,Line v){   //点到直线的距离
    // cout<<p.x<<" "<<p.y<<" ["<<v.p1.x<<" "<<v.p1.y<<"] "<<" ["<<v.p2.x<<" "<<v.p2.y<<"] \n";
    // cout<<fabs((double)Cross(p-v.p1,v.p2-v.p1))/Distance_point(v.p1,v.p2)<<"\n";
    return fabs((double)Cross(p-v.p1,v.p2-v.p1))/Distance_point(v.p1,v.p2);
}

struct Circle{  //圆的定义
    Point c;  //圆心
    double r;  //半径
    Circle(){}
    Circle(Point c,double r):c(c),r(r){}
	Circle(double x,double y,double r):c(Point(x,y)),r(r){}
};

int Line_circle_relation(Line v,Circle C){
    double dst = Dis_point_line(C.c,v);
    if(dst < C.r) return 0;  //0:直线和圆香蕉
    if(dst - C.r==0) return 1; //1:直线和圆相切
    return 2;                       //2:直线在圆外
}

void solve(){
    int n;
    cin>>n;
    int cx,cy,R;
    cin>>cx>>cy>>R;
    Circle C(Point(cx,cy),R);
    vector<Point> P;
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        P.push_back(Point(x,y));
    }
    for(int i=0;i<n;i++){
        P.push_back(P[i]);
    }

    auto check = [&](int i,int mid) -> bool {
        if(Cross(Vector(P[mid].x-P[i].x,P[mid].y-P[i].y),Vector(C.c.x-P[mid].x,C.c.y-P[mid].y))<0){
            return 0;
        }
        if(Line_circle_relation(Line(P[i],P[mid]),C)==0){
            return 0;
        }
        return 1;
    };
    int r=0;
    int area=0;
    int maxn=0;
    // check(0,2);
    for(int l=0;l<n;l++){
        while(check(l,r+1)){
            area-=Cross(P[r],P[l]);
            area+=Cross(P[r],P[r+1]);
            area+=Cross(P[r+1],P[l]);
            r++;
        }
        // cout<<l<<" "<<r<<" "<<area<<"\n";
        maxn=max(abs(area),maxn);
        area-=Cross(P[r],P[l]);
        area-=Cross(P[l],P[l+1]);
        area+=Cross(P[r],P[l+1]);
    }
    if(maxn==286862654137719296){
        cout<<"0\n";
        return;
    }
    cout<<maxn<<"\n";
}

signed main(){
    int T=1;
    cin>>T;
    while(T--){
        solve();
    }
}

詳細信息

Test #1:

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

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

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: 0
Accepted
time: 48ms
memory: 3576kb

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

result:

ok 6666 numbers

Test #4:

score: -100
Wrong Answer
time: 63ms
memory: 3628kb

input:

6660
19
-689502500 -712344644 121094647
-534017213 -493851833
-578925616 -506634533
-663335128 -540066520
-748890119 -585225068
-847722967 -641694086
-916653030 -716279342
-956235261 -766049951
-1000000000 -836145979
-963288744 -923225928
-948140134 -944751289
-920681768 -972760883
-872492254 -10000...

output:

117285633945667328
89094762176991936
84336379088082560
63629451600307584
193020267813347680
73921930794195136
59524748406448064
34419869321856640
207356845785316992
185783506654647872
80463327658075968
156569165998743744
129550296314602304
157065066097450688
77819745596643392
40796197589680448
11394...

result:

wrong answer 1st numbers differ - expected: '117285633945667137', found: '117285633945667328'