QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#671064 | #7013. Rikka with Ants | pengpeng_fudan | WA | 36ms | 3796kb | C++23 | 2.4kb | 2024-10-24 10:33:09 | 2024-10-24 10:33:09 |
Judging History
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);
if((q1!=0&&q1!=1)){
if(q2==1){
if(g[0].second>g[2].second) q1=0;
else q1=1;
}
else if(q2==0){
if(g[1].second>g[3].second) q1=0;
else q1=1;
}
}
if((q2!=0&&q2!=1)){
if(q1==1){
if(g[0].second>g[1].second) q2=0;
else q2=1;
}
else if(q1==0){
if(g[2].second>g[3].second) q2=0;
else q2=1;
}
}
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: 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 2 14.66666666666667 14.66666666666667
result:
ok 2 cases
Test #2:
score: -100
Wrong Answer
time: 36ms
memory: 3724kb
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 30 571.6288659793814 571.6288659793814 8 22 419 87 728.8988764044944 728.8988764044944 469 309 509.9169811320755 509.9169811320755 87 63 80 36 157 99 780 300 283 88 1000 851 216 626 424.0752941176471 424.0752941176471 944 456 179 122 687.9125683060109 687.9125683060109 62.85714285714286 62.857142...
result:
wrong answer In case 4, the first value expected '378.000000000000', but found '419.000000000000', error '0.097852028640'.