QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#732775#5978. Runaway Quailthomas07020 6ms19900kbC++142.6kb2024-11-10 15:52:282024-11-10 15:52:31

Judging History

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

  • [2024-11-10 15:52:31]
  • 评测
  • 测评结果:0
  • 用时:6ms
  • 内存:19900kb
  • [2024-11-10 15:52:28]
  • 提交

answer

#include<bits/stdc++.h>
#define ld long double
#define eps 1e-8
using namespace std;
void rd(){}
template<typename T,typename... U> void rd(T &x,U&... arg){
	x=0;int f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
	x*=f;rd(arg...);
}
const int maxn=505;
const ld inf=1e15;
template<typename T> inline T ABS(T n){return max(n,-n);}
inline int dcmp(ld a,ld b){return a<b-eps?-1:a>b+eps?1:0;}
int N,X,Y;
ld C,__a[maxn],__b[maxn],xl[maxn],yl[maxn];
struct Point{
	ld x,y;Point(ld x=0,ld y=0):x(x),y(y){}
	friend bool operator<(Point a,Point b){
		return dcmp(a.x,b.x)==-1||
		(dcmp(a.x,b.x)==0&&dcmp(ABS(a.y),ABS(b.y))==-1);
	}
}f[maxn][maxn][2];
struct ikun{ld a,b;ikun(ld a=0,ld b=0):a(a),b(b){}}x[maxn],y[maxn];
inline bool cmp(ikun x,ikun y){return ABS(x.a)!=ABS(y.a)?ABS(x.a)>ABS(y.a):ABS(x.b)>ABS(y.b);}
inline Point Cross(ikun x,ikun y){ld __x=(y.a-x.a)/(x.b-y.b);return Point(__x,__x*x.b+x.a);}
ikun q[maxn];
void func(ikun *arr,int &n,ld *lf){
	if(!n) return;
	sort(arr+1,arr+n+1,cmp);
	int p=1;q[1]=arr[1],lf[1]=0;
	for(int i=2;i<=n;i++){
		if(ABS(arr[i].b)<=ABS(q[p].b)+eps) continue;
		Point c=Cross(q[p],arr[i]);
		while(p>1&&lf[p]>=c.x-eps) c=Cross(q[--p],arr[i]);
		q[++p]=arr[i],lf[p]=c.x;
	}
	n=p;
	reverse(q+1,q+p+1);
	reverse(lf+1,lf+p+1);
	for(int i=1;i<=p;i++) arr[i]=q[i];
}
void solve(){
	rd(C,N);
	for(int i=1;i<=N;i++) rd(__a[i]);
	for(int i=1;i<=N;i++) rd(__b[i]);
	X=Y=0;
	for(int i=1;i<=N;i++)
		if(__a[i]>0) x[++X]=ikun(__a[i],__b[i]);
		else y[++Y]=ikun(__a[i],-__b[i]);
	func(x,X,xl);
	func(y,Y,yl);
	for(int i=0;i<=X;i++)
		for(int j=0;j<=Y;j++)
			f[i][j][0]=f[i][j][1]=Point(inf,0);
	f[0][0][0]=f[0][0][1]=Point(0,0);
	for(int i=0;i<=X;i++)
		for(int j=0;j<=Y;j++){
			if(i<X)
				for(int k=0;k<2;k++)
					if(f[i][j][k].x<inf){
						Point c=Cross(x[i+1],ikun(f[i][j][k].y-f[i][j][k].x*C,C));
						if(dcmp(c.x,xl[i+1])!=-1) f[X][j][0]=min(c,f[X][j][0]);
						else f[i+1][j][0]=min(c,f[i+1][j][0]);
					}
			if(j<Y)
				for(int k=0;k<2;k++)
					if(f[i][j][k].x<inf){
						Point c=Cross(y[j+1],ikun(f[i][j][k].y+f[i][j][k].x*C,-C));
						if(dcmp(c.x,yl[j+1])!=-1) f[i][Y][1]=min(c,f[i][Y][1]);
						else f[i][j+1][1]=min(c,f[i][j+1][1]);
					}
		}
	printf("%.9Lf\n",min(f[X][Y][0],f[X][Y][1]).x);
}
int main(){
//	freopen("tiii.in","r",stdin);
//	freopen("ex_tiii4.in","r",stdin);
//	freopen("tiii.out","w",stdout);
	int T;rd(T);
	for(int i=1;i<=T;i++)
		printf("Case #%d: ",i),solve();
//	while(T--) solve();
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 19836kb

input:

50
4 3
-3 -6 -9
3 2 1
2 2
1 -1
1 1
1000 25
769234 -5735820 -524288 -5403090 -6429140 1574982 1 -9733628 -1407481 4093041 4117720 -3193501 -9765195 -3069520 1122216 -5799108 131072 -8482066 -256 -8021159 -8958386 -7027036 5370579 -3602534 -6834567
425 102 744 155 339 19 999 19 159 198 51 304 369 601 ...

output:

Case #1: 3.000000000
Case #2: 5.000000000
Case #3: 39483.842372738
Case #4: 429262.396142110
Case #5: 20919.216624685
Case #6: 7729.966650488
Case #7: 57745.858867521
Case #8: 607220.690423515
Case #9: 5725896.876344086
Case #10: 20892.903144654
Case #11: 52246.871533478
Case #12: 610881.705159705
C...

result:

wrong answer read 39483.842372738000 but expected 51133.937500000000 (test case 3)

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 6ms
memory: 19900kb

input:

50
4 3
-3 -6 -9
3 2 1
2 2
1 -1
1 1
1000 500
-9650379 9806301 -6495789 -1283284 5022779 4725553 9364178 -8123302 -9609729 7847458 -142364 6983908 8147008 -3186924 7339254 -8737645 8757174 7887319 3609962 5780915 -1752801 -1657946 -9511339 5113995 -7887160 -6093170 260267 -3837106 -356098 6676924 6210...

output:

Case #1: 3.000000000
Case #2: 5.000000000
Case #3: 205911250.088888889
Case #4: 35417.050493571
Case #5: 131687.180115401
Case #6: 13741948.500000000
Case #7: 100892.316130531
Case #8: 36822.890819286
Case #9: 20840.474278545
Case #10: 8069407.987096774
Case #11: 20840.474278545
Case #12: 95439.6584...

result:

wrong answer read 35417.050493570998 but expected 36298.000000000000 (test case 4)