QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#671033#7013. Rikka with Antspengpeng_fudanWA 36ms3872kbC++232.0kb2024-10-24 10:10:392024-10-24 10:10:39

Judging History

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

  • [2024-10-24 10:10:39]
  • 评测
  • 测评结果:WA
  • 用时:36ms
  • 内存:3872kb
  • [2024-10-24 10:10:39]
  • 提交

answer

#include<bits/stdc++.h>
#define double long double
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)   cin>>a[i];
    int s1,e1,s2,e2;
    cin>>s1>>e1>>s2>>e2;s1--,e1--,s2--,e2--;
    pair<int,int> g[4];
    auto get=[&](int s1,int e1,int s2,int e2)->double {
        for(int i=0;i<4;i++){
            g[i]={0,0};
            vector<int> lzg(n);
            int t1=((i&1)?-1:1),t2=((i>>1&1)?-1:1);
            for(int j=s1;j!=e1;j=(j+t1+n)%n)    {
                t1==1?lzg[j]++:lzg[(j-1+n)%n]++;
            }
            for(int j=s2;j!=e2;j=(j+t2+n)%n)    {
                t2==1?lzg[j]++:lzg[(j-1+n)%n]++;
            }
            for(int j=s1;j!=e1;j=(j+t1+n)%n)    {
                int w=(t1==1?(lzg[j]==2?3:1):(lzg[(j-1+n)%n]==2?3:1));
                g[i].first+=w*(t1==1?a[j]:a[(j-1+n)%n]);
            }
            for(int j=s2;j!=e2;j=(j+t2+n)%n){
                int w=(t2==1?(lzg[j]==2?3:1):(lzg[(j-1+n)%n]==2?3:1));
                g[i].second+=w*(t2==1?a[j]:a[(j-1+n)%n]);
            }
        }
        int a0=g[0].first,a1=g[1].first,a2=g[2].first,a3=g[3].first;
        if(a0-a1-a2+a3==0)  {
            return a2<=a3?1:0;
        } 
        if(a0>=a1&&a2>=a3)  return 0;
        else if(a0<=a1&&a2<=a3) return 1;
        double ans=(double)(a3-a1)/(a0-a1-a2+a3);
        if(ans>1)   ans=1;
        if(ans<0)   ans=0;
        return ans;
    };
    double q1,q2;
    q1=get(s1,e1,s2,e2);
    swap(s1,s2),swap(e1,e2);
    q2=get(s1,e1,s2,e2);
    // cerr<<q1<<' '<<q2<<"?"<<'\n';
    cout<<setprecision(16)<<q2*q1*g[0].second+(1-q2)*q1*g[1].second+q2*(1-q1)*g[2].second+(1-q2)*(1-q1)*g[3].second<<' ';
    cout<<setprecision(16)<<q2*q1*g[0].first+(1-q2)*q1*g[1].first+q2*(1-q1)*g[2].first+(1-q2)*(1-q1)*g[3].first<<'\n';
}   
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int _ = 1;
    cin>>_;
    while(_--)  solve();
}
/*
1
5
8 22 47 25 13
3 5 3 1
*/
/*
1
5
1 5 2 4 3
1 3 2 4

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1 2
14.66666666666667 14.66666666666667

result:

ok 2 cases

Test #2:

score: -100
Wrong Answer
time: 36ms
memory: 3776kb

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:

97.07865168539326 78.53932584269663
571.6288659793814 571.6288659793814
8 22
419 87
728.8988764044944 728.8988764044944
469 309
509.9169811320755 509.9169811320755
212.8543689320388 169.4271844660194
80 36
157 99
780 300
283 88
1000 851
576.0958721704394 720.1917443408788
424.0752941176471 424.07529...

result:

wrong answer In case 1, the first value expected '72.000000000000', but found '97.078651685393', error '0.258333333333'.