QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#528326#8266. Astronomer-xcxxx-Compile Error//C++141.2kb2024-08-23 12:45:162024-08-23 12:45:18

Judging History

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

  • [2024-08-23 12:45:18]
  • 评测
  • [2024-08-23 12:45:16]
  • 提交

answer

#include<bits/stdc++.h>
#define double long double
using namespace std;
int rd() {int x=0,f=1;char c=getchar();while(!isdigit(c))f=c=='-'?-1:f,c=getchar();while(isdigit(c))x=x*10+(c^48),c=getchar();return x*f;}
const int N=705;
int n,k,s,t;
double rng() {return 1.0*rand()/RAND_MAX;}
struct point {double x,y;}p[N];
double d[N];
double sq(double x) {return x*x;}
double dis(point a,point b) {
//	printf("# %Lf-%Lf=%Lf\n",a.x,b.x,a.x-b.x);
	return sqrt(sq(a.x-b.x)+sq(a.y-b.y));
}
double calc(point o) {
	for(int i=1;i<=n;i++) d[i]=dis(p[i],o);
	nth_element(d+1,d+k,d+1+n);
//	printf("o=(%Lf,%Lf) res=%Lf+%Lf\n",o.x,o.y,dis(o,{0,0})*s,d[k]*t);
	return dis(o,{0.0,0.0})*s+d[k]*t;
}
double ans=1e20;
void SA(double T,point o,double now,double lim) {
	while(T>lim) {
		ans=min(ans,now);
		point no={o.x+T*(rng()*2-1),o.y+T*(rng()*2-1)};
		double delta=calc(no)-now;
		if(exp(-delta/T)>rng()) o=no,now+=delta;
		T*=0.999;
	}
	if(lim>99) ::T=T,::o=o,::now=now;
}
signed main() {
	srand(time(0));
	int t_st=clock();
	k=rd(),n=rd(),s=rd(),t=rd();
	for(int i=1;i<=n;i++) p[i].x=rd(),p[i].y=rd();
	while(clock()-t_st<1.8*CLOCKS_PER_SEC) SA(1000000000,{0,0},calc({0,0}),100);
	printf("%.15Lf\n",ans);
    return 0;
}

詳細信息

answer.code: In function ‘void SA(long double, point, long double, long double)’:
answer.code:30:22: error: ‘::T’ has not been declared
   30 |         if(lim>99) ::T=T,::o=o,::now=now;
      |                      ^
answer.code:30:28: error: ‘::o’ has not been declared
   30 |         if(lim>99) ::T=T,::o=o,::now=now;
      |                            ^
answer.code:30:34: error: ‘::now’ has not been declared
   30 |         if(lim>99) ::T=T,::o=o,::now=now;
      |                                  ^~~