QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#662029#9434. Italian Cuisinekepu1625WA 1ms4048kbC++202.4kb2024-10-20 20:10:152024-10-20 20:10:28

Judging History

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

  • [2024-10-20 20:10:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4048kb
  • [2024-10-20 20:10:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
long long cross(pair<ll,ll>a,pair<ll,ll>b){
    return (1ll*a.first*b.second-1ll*a.second*b.first);
}
double dis(pair<ll,ll>a,pair<ll,ll>b,pair<ll,ll>o){
    if(a.first==b.first)return abs(a.first-o.first);
    double k=double(a.second-b.second)/(double)(a.first-b.first);
    double B=(double)a.second-k*a.first;
    double tmp=abs(k*o.first-(double)o.second+B)/sqrtl(k*k+(double)1);
    return abs(k*o.first-(double)o.second+B)/sqrtl(k*k+(double)1);
}
pair<ll,ll> reduce(pair<ll,ll>a,pair<ll,ll>b){
    return make_pair(a.first-b.first,a.second-b.second);
}
double Cos(pair<ll,ll>a,pair<ll,ll>b){
    double tmp=a.first*b.first+a.second*b.second;
    double m1=a.first*a.first+a.second*a.second;
    double m2=b.first*b.first+b.second*b.second;
    return tmp/sqrtl(m1)/sqrtl(m2);
}
void solve(){
    int R,x0,y0;
    int n;
    cin>>n>>x0>>y0>>R;
    vector<pair<ll,ll>>a;
    for(int i=1;i<=n;i++){
        pair<ll,ll>tmp;
        cin>>tmp.first>>tmp.second;
        a.push_back(tmp);
    }
    ll l=0,r=1;
    bool check1=0,check2=0;
    long long ans=0;
    long long sum=0;
    long long tot=0;
    // for(int i=0;i<n;i++){
    //     tot+=cross(a[i],a[(i+1)%n]);
    // }
    while(1){
        sum-=cross(a[r],a[l]);
        if(l==r||dis(a[(r+1)%n],a[l],make_pair(x0,y0))>=R&&acos(Cos(reduce(a[l],make_pair(x0,y0)),reduce(a[l],a[r])))>=acos(Cos(reduce(a[l],a[r]),reduce(a[l],a[(r+1)%n])))){
            sum+=cross(a[r],a[(r+1)%n]);
            r=((r+1)%n);
            sum+=cross(a[r],a[l]);
        }
        else {
            sum-=cross(a[l],a[(l+1)%n]);
            if(l+1>=n)break;
            l=(l+1)%n;
            sum+=cross(a[r],a[l]);
        }
        ans=max(ans,abs(sum));
    }
    l=1,r=2,sum=0;
    while(1){
        sum-=cross(a[r],a[l]);
        if(l==r||dis(a[(r+1)%n],a[l],make_pair(x0,y0))>=R&&acos(Cos(reduce(a[l],make_pair(x0,y0)),reduce(a[l],a[r])))>=acos(Cos(reduce(a[l],a[r]),reduce(a[l],a[(r+1)%n])))){
            sum+=cross(a[r],a[(r+1)%n]);
            r=((r+1)%n);
            sum+=cross(a[r],a[l]);
        }
        else {
            sum-=cross(a[l],a[(l+1)%n]);
            if(l+1>=n)break;
            l=(l+1)%n;
            sum+=cross(a[r],a[l]);
        }
        ans=max(ans,abs(sum));
    }
    cout<<ans<<endl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)solve();
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 4048kb

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: 1ms
memory: 3768kb

input:

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

output:

286862654137719264

result:

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