QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#609233#9434. Italian CuisineRosmontispesCompile Error//C++202.8kb2024-10-04 11:21:192024-10-04 11:21:20

Judging History

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

  • [2024-10-04 11:21:20]
  • 评测
  • [2024-10-04 11:21:19]
  • 提交

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(ross(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 >= 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();
}

Details

answer.code: In function ‘void solve()’:
answer.code:60:16: error: ‘ross’ was not declared in this scope; did you mean ‘Cross’?
   60 |             if(ross(poi[j],cir,poi[st]) * Cross(poi[nex],cir,poi[st]) <= 0)
      |                ^~~~
      |                Cross