QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#671597 | #7013. Rikka with Ants | MoQz | WA | 14ms | 3864kb | C++14 | 2.1kb | 2024-10-24 13:37:08 | 2024-10-24 13:37:08 |
Judging History
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){
if(X4<0){
p2=0;
p1=X2<0?1:0;
}
else {
p2=1;
p1=X2+X4<0?1: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){
if(Y4<0){
p1=0;
p2=Y3<0?1:0;
}
else {
p1=1;
p2=Y3+Y4<0?1:0;
}
}
}
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
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: -100
Wrong Answer
time: 14ms
memory: 3864kb
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 419.000000000000 87.000000000000 728.898876404494 728.898876404494 469.000000000000 309.000000000000 509.916981132075 509.916981132075 236.000000000000 189.000000000000 80.000000000000 36.000000000000 97...
result:
wrong answer In case 4, the first value expected '378.000000000000', but found '419.000000000000', error '0.097852028640'.