QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575479#3195. Within Arm's ReachqwqUwU_WA 0ms4196kbC++141.7kb2024-09-19 14:41:572024-09-19 14:42:00

Judging History

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

  • [2024-09-19 14:42:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4196kb
  • [2024-09-19 14:41:57]
  • 提交

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);
	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);
	if(px==0&&py==0)px=py=eps,len=sqrt(px*px+py*py);
	double s=0,s2=0;rep(i,1,n)s+=a[i];
	double X=0,Y=0;
	bool fl1=0,fl2=0;
	if(px<0)fl1=1,px=-px;
	if(py<0)fl2=1,py=-py;
	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; 
			}
			s-=a[j];s2+=len;
			double k=py/px;
			double c=(a[j]*a[j]+s2*s2-s*s)/(2*a[j]*s2);
			double theta=acos(c)+atan(k);
			x[j]=a[j]*cos(theta);
			y[j]=a[j]*sin(theta);
			c=(s2*s2+s*s-a[j]*a[j])/(2*s*s2);
			theta=atan(k)-acos(c);
			rep(j,i+1,n){
				int k=id[j];
				x[k]=a[k]*cos(theta);
				y[k]=a[k]*sin(theta);
			}
			break;
		}
	}
	rep(i,1,n){
		x[i]+=x[i-1],y[i]+=y[i-1];
		printf("%.6lf %.6lf\n",fl1?-x[i]:x[i],fl2?-y[i]:y[i]);
	}
    return 0;
}

詳細信息

Test #1:

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

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: 3788kb

input:

1
10
10 0

output:

10.000000 0.000000

result:

ok ACCEPTED

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 4196kb

input:

1
10
0 0

output:

nan nan

result:

wrong output format Expected double, but "nan" found