QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109336#5667. Meeting PlaceschenshiWA 4ms10308kbC++1.4kb2023-05-28 15:08:142023-05-28 15:08:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-28 15:08:19]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:10308kb
  • [2023-05-28 15:08:14]
  • 提交

answer

#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
const int o=2010,v1=233811181,v2=(1ll<<31)-1;const double inf=1e18,eps=1e-6;
int n,K,X[o],Y[o],tp[o],st[o][o];double f[o][o],c[o][o],ox,oy,R;
inline pair<double,double> calc2(double X1,double Y1,double X2,double Y2){
	double k=(X2-X1)/(Y1-Y2),x=(X1+Y1)/2,y=(X2+Y2)/2;
	return make_pair(k,y-k*x);
}
inline void calc1(pair<double,double> l1,pair<double,double> l2,double&x,double&y){
	x=(l1.second-l2.second)/(l2.first-l1.first);y=x*l1.first+l1.second;
}
inline double dis(int t){return sqrt((ox-X[t])*(ox-X[t])+(oy-Y[t])*(oy-Y[t]));}
inline bool chk(int t){return dis(t)<R+eps;}
int main(){
	scanf("%d%d%d",&n,&K,&X[1]);
	for(int i=1;i<=n;++i){
		if(i>1) X[i]=(Y[i-1]*1ll*v1+1)%v2;
		Y[i]=(X[i]*1ll*v1+1)%v2;f[0][i]=inf;
	}
	for(int i=1;i<=n;++i){
		R=-1;
		for(int j=i;j;--j) if(!chk(j)){
			if(j<i) st[i][++tp[i]]=j+1,c[i][tp[i]]=R;
			ox=X[j];oy=Y[j];R=0;
			for(int k=i;k>j;--k) if(!chk(k)){
				ox=(X[j]+0.0+X[k])/2;oy=(Y[j]+0.0+Y[k])/2;R=dis(k);
				for(int $=i;$>k;--$)
					if(!chk($)) calc1(calc2(X[j],Y[j],X[k],Y[k]),calc2(X[j],Y[j],X[$],Y[$]),ox,oy),R=dis($);
			}
		}
		st[i][++tp[i]]=1;c[i][tp[i]]=R;
	}
	for(int i=1;i<=K;++i) for(int j=1;j<=n;++j){
		f[i][j]=inf;
		for(int k=1;k<=tp[j];++k) f[i][j]=min(f[i][j],f[i-1][st[j][k]-1]+c[j][k]);
	}
	printf("%lf",f[K][n]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 10308kb

input:

100 23 213

output:

1319350480.800733

result:

ok found '1319350480.8007331', expected '1319350480.8007326', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 7956kb

input:

10 1 1060

output:

1042753143.345168

result:

ok found '1042753143.3451680', expected '1042753143.3451676', error '0.0000000'

Test #3:

score: 0
Accepted
time: 3ms
memory: 9784kb

input:

10 10 2373

output:

0.000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 5896kb

input:

10 2 3396

output:

1552685093.905248

result:

wrong answer 1st numbers differ - expected: '1236610536.9469230', found: '1552685093.9052479', error = '0.2555975'