QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671659#7013. Rikka with AntsMoQzAC ✓17ms3796kbC++142.1kb2024-10-24 13:55:392024-10-24 13:55:41

Judging History

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

  • [2024-10-24 13:55:41]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:3796kb
  • [2024-10-24 13:55:39]
  • 提交

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;
    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;
    long double p1=-1,p2=-1;
    if(X2<=0&&A[0][0].first<=A[1][0].first){
        p1=0;
        if(A[0][0].second<=A[0][1].second)p2=0;
        else p2=1;
    }
    if(Y3<=0&&A[0][0].second<=A[0][1].second){
        p2=0;
        if(A[0][0].first<=A[1][0].first)p1=0;
        else p1=1;
    }
    if(X2>=0&&A[0][0].first>=A[1][0].first){
        p1=1;
        if(A[1][0].second<=A[1][1].second)p2=0;
        else p2=1;
    }
    if(Y3>=0&&A[0][0].second>=A[0][1].second){
        p2=1;
        if(A[0][1].first<=A[1][1].first)p1=0;
        else p1=1;
    }
    if(p2==-1){
        p2=X2*(-1.0)/X4;
    }
    else p2=1-p2;
    if(p1==-1){
        p1=Y3*(-1.0)/Y4;
    }
    else p1=1-p1;
    long double ans1=X1+X2*p1+X3*p2+X4*p1*p2;
    long double ans2=Y1+Y2*p1+Y3*p2+Y4*p1*p2;
    printf("%.12Lf %.12Lf\n",ans1,ans2);
}
int main(){
    int T;
    scanf("%d",&T);
    while(T){
        --T;
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

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

output:

1.000000000000 2.000000000000
14.666666666667 14.666666666667

result:

ok 2 cases

Test #2:

score: 0
Accepted
time: 17ms
memory: 3792kb

input:

5000
5
8 22 47 25 13
3 5 3 1
20
9 24 41 8 23 31 48 15 46 5 17 36 29 40 36 43 34 33 29 26
16 4 15 5
3
8 22 33
1 2 2 3
26
18 44 37 21 44 44 5 15 43 44 44 37 19 10 22 14 41 37 42 18 14 34 3 17 30 42
13 2 13 15
26
31 31 41 11 35 49 13 29 33 11 27 6 16 25 47 40 2 33 27 35 35 29 48 35 5 7
17 3 13 3
26
30 ...

output:

72.000000000000 30.000000000000
571.628865979381 571.628865979381
8.000000000000 22.000000000000
378.000000000000 29.000000000000
728.898876404494 728.898876404494
356.000000000000 103.000000000000
509.916981132075 509.916981132075
87.000000000000 63.000000000000
80.000000000000 36.000000000000
157....

result:

ok 5000 cases