QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601591#7127. 3 pointsdongyc666WA 62ms4112kbC++141.0kb2024-09-30 08:42:332024-09-30 08:42:34

Judging History

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

  • [2024-09-30 08:42:34]
  • 评测
  • 测评结果:WA
  • 用时:62ms
  • 内存:4112kb
  • [2024-09-30 08:42:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int NR=1010;
//模拟退火 
#define int long long
#define ld long double
ld x[NR],y[NR],w[NR];
ld res,resx,resy;
ld ans,ansx,ansy;
ld sol,solx,soly;
mt19937_64 rnd(time(0));
const ld D=0.98;
const ld eps=1e-14;
int n;
const int MOD=1ll<<30;
ld Rand(){return (rnd()%MOD)*2-MOD;}
ld cal(ld x1,ld y1,ld x2,ld y2){
	ld lcy1=(x1-x2)*(x1-x2);
	ld lcy2=(y1-y2)*(y1-y2);
	return sqrt(lcy1+lcy2);
}
ld calc(ld x0,ld y0){
	ld res=0;
	for(int i=1;i<=3;i++)res+=cal(x0,y0,x[i],y[i])*w[i];
	return res;
}
signed main(){
	n=3;
	for(int i=1;i<=3;i++){
		scanf("%Lf%Lf",&x[i],&y[i]);
		w[i]=i;
		solx+=x[i];soly+=y[i];
	}
	sol=ans=calc(solx/=n,soly/=n);
	int times=100;
	while(times--){
		ans=sol;ansx=solx;ansy=soly;
		for(ld T=100000;T>eps;T*=D){
			resx=ansx+Rand()*T,resy=ansy+Rand()*T;
			res=calc(resx,resy);
			if(sol>res){sol=res;solx=resx;soly=resy;}
			if(ans>res||exp((ans-res)/T)>(ld)rand()/MOD){ans=res;ansx=resx;ansy=resy;}
		}
	}
	printf("%.10Lf\n",ans);
	return 0;
} 

详细

Test #1:

score: 100
Accepted
time: 62ms
memory: 4060kb

input:

0 0
0 0
1 0

output:

3.0000000000

result:

ok found '3.0000000', expected '3.0000000', error '0.0000000'

Test #2:

score: -100
Wrong Answer
time: 62ms
memory: 4112kb

input:

3802 -1400
-1785 6079
-1696 4064

output:

18642.6377440798

result:

wrong answer 1st numbers differ - expected: '11785.2709213', found: '18642.6377441', error = '0.5818591'