QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#671427#7013. Rikka with AntsMoQzWA 0ms3936kbC++141.9kb2024-10-24 12:22:052024-10-24 12:22:06

Judging History

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

  • [2024-10-24 12:22:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3936kb
  • [2024-10-24 12:22:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
int n;
int a[51];
pair<int,int>A[2][2];
int bz[51];
pair<int,int> Get(int a1,int b1,int a2,int b2){
    fo(i,1,n)bz[i]=0;
    pair<int,int>u={0,0};
    while(a1!=b1){
        ++bz[a1];
        u.first+=a[a1];
        ++a1;
        if(a1==n+1)a1=1;
    }
    while(a2!=b2){
        ++bz[a2];
        u.second+=a[a2];
        ++a2;
        if(a2==n+1)a2=1;
    }
    fo(i,1,n){
        if(bz[i]==2)u.first+=a[i]*2,u.second+=a[i]*2;
    }
    return u;
}
void solve(){
    scanf("%d",&n);
    fo(i,1,n)scanf("%d",&a[i]);
    int s1,e1,s2,e2;
    scanf("%d%d%d%d",&s1,&e1,&s2,&e2);
    fo(i,0,1){
        fo(j,0,1){
            A[i][j]=Get(s1,e1,s2,e2);
            swap(s2,e2);
        }
        swap(s1,e1);
    }
    int X1=A[1][1].first,X2=A[0][1].first-A[1][1].first,X3=A[1][0].first-A[1][1].first,X4=A[0][0].first+A[1][1].first-A[0][1].first-A[1][0].first;
    long double p1=0,p2=0;
    if(X4==0){
        if(X2<0)p1=1;
        else p1=0;
    }
    else{
        p2=X2*(-1.0)/X4;
        if(p2<0||p2>1){
            p2=min(p2,(long double)1);
            p2=max(p2,(long double)0);
        }
    }
    int Y1=A[1][1].second,Y2=A[0][1].second-A[1][1].second,Y3=A[1][0].second-A[1][1].second,Y4=A[0][0].second+A[1][1].second-A[0][1].second-A[1][0].second;
    if(Y4==0){
        if(Y3<0)p2=1;
        else p2=0;
    }
    else{
        p1=Y3*(-1.0)/Y4;
        if(p1<0||p1>1){
            p1=min(p1,(long double)1);
            p1=max(p1,(long double)0);
        }
    }
    long double ans1=X1+X2*p1+X3*p2+X4*p1*p2;
    long double ans2=Y1+Y2*p1+Y3*p2+Y4*p1*p2;
    printf("%Lf %Lf\n",ans1,ans2);
}
int main(){
    // freopen("k.in","r",stdin);
    int T;
    scanf("%d",&T);
    while(T){
        --T;
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3936kb

input:

2
5
1 5 2 4 3
1 2 3 4
5
1 5 2 4 3
1 3 2 4

output:

1.000000 2.000000
14.666667 14.666667

result:

wrong answer In case 2, the first value expected '14.666666666667', but found '14.666667000000', error '0.000000022727'.