QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#575440 | #3195. Within Arm's Reach | qwqUwU_ | WA | 0ms | 3968kb | C++14 | 1.9kb | 2024-09-19 14:21:21 | 2024-09-19 14:21:23 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcountll(s)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
inline ll read(){
ll x=0,f=1,c=getchar();
while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
const int N=23;
const double eps=1e-8;
int n,id[N];
double a[N],x[N],y[N];
int main() {
//freopen("data.in", "r", stdin);
// freopen("myans.out","w",stdout);
n=read();rep(i,1,n)a[i]=read(),id[i]=i;
sort(id+1,id+n+1,[](int i,int j){return a[i]<a[j];});
double px=read(),py=read(),len=sqrt(px*px+py*py);
double s=0,s2=0;rep(i,1,n)s+=a[i];
double X=0,Y=0;
if(s<=len){
rep(i,1,n){
x[i]=px*(a[i]/len);
y[i]=py*(a[i]/len);
}
}
else{
rep(i,1,n){
int j=id[i];
if(s-s2-2*a[j]>=len){
s2+=a[j];s-=a[j];
x[j]=-px*(a[j]/len);
y[j]=-py*(a[j]/len);
X+=x[j],Y+=y[j];
continue;
}
if(i==n){
if(len==0)x[j]=a[j],y[j]=0;
else x[j]=px*(a[j]/len),y[j]=py*(a[j]/len);
break;
}
s-=a[j];s2+=len;
double k=py/px;
double c=(a[j]*a[j]+s2*s2-s*s)/(2*a[j]*s2);
double t=sqrt(1-c*c)/c;
double k2=(k+t)/(1-k*t);k2*=k2;
x[j]=a[j]*sqrt(1/(1+k2));
y[j]=a[j]*sqrt(k2/(1+k2));
c=(s2*s2+s*s-a[j]*a[j])/(2*s*s2);
t=sqrt(1-c*c)/c;
k2=(k-t)/(1+k*t);k2*=k2;
rep(j,i+1,n){
int k=id[j];
x[k]=a[k]*sqrt(1/(1+k2));
y[k]=a[k]*sqrt(k2/(1+k2));
}
break;
}
}
rep(i,1,n){
//double len=sqrt(x[i]*x[i]+y[i]*y[i]);
//assert(fabs(len-a[i])<=eps);
x[i]+=x[i-1],y[i]+=y[i-1];
printf("%.6lf %.6lf\n",x[i],y[i]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
2 4 2 -8 -3
output:
-3.745317 -1.404494 -5.617975 -2.106741
result:
ok ACCEPTED
Test #2:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 10 10 0
output:
10.000000 0.000000
result:
ok ACCEPTED
Test #3:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
1 10 0 0
output:
10.000000 0.000000
result:
ok ACCEPTED
Test #4:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
2 10 5 2 2
output:
7.071068 7.071068 3.535534 3.535534
result:
ok ACCEPTED
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3928kb
input:
3 100 20 20 80 90
output:
77.906765 62.693987 91.394883 77.461203 106.976236 90.000000
result:
wrong answer WRONG ANSWER: segment exceeds EPSILON diff = 26.976236