QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#752855 | #3566. Cycling | gyydp123_LIM | 0 | 0ms | 0kb | C++20 | 2.1kb | 2024-11-16 10:08:46 | 2024-11-16 10:08:47 |
Judging History
answer
//Start: 2024-11-16 09:22:38
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt, __func__, __LINE__, ##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=605;
const double inf=1e18,A=0.5,eps=1e-5;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')
x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return x*f;
}
double X;int m;
struct Light{double x,r,g;}a[N];
double f[11][N];
double solve(double A,double B,double C){
return (-B+sqrt(B*B-4*A*C))/(2*A);}
void ljy(){
For(i,1,m) scanf("%lf%lf%lf",&a[i].x,&a[i].r,&a[i].g);
For(j,0,10) For(i,0,N-1) f[j][i]=-inf;f[0][0]=0;
sort(a+1,a+1+m,[](Light a,Light b){return a.x<b.x;});
For(i,1,m) For(j,1,N-5) For(x,0,i-1) For(y,0,N-5) if(f[x][y]>=-eps){
double x2=a[i].x,t2=j/2*(a[i].r+a[i].g)+(j&1)*a[i].r;
double x1=a[x].x,t1=y/2*(a[x].r+a[x].g)+(y&1)*a[i].r,lim=f[x][y];
double dt=t2-t1,dx=x2-x1;
if(dt<0) continue;
double v0=(dx-dt*dt/2*A)/dt;
if(v0>lim) continue;
if(v0<0) t1=t2-sqrt(dx*2/A),v0=0;
bool flg=1;
For(k,x+1,i-1){
double dx=a[k].x-a[x].x;
double nt=t1+solve(A/2,v0,-dx);
double rst=nt-(int)(nt/(a[k].g+a[k].r))*(a[k].g+a[k].r);
if(rst<a[k].r-eps){flg=0;break;}
}if(flg) f[i][j]=max(f[i][j],sqrt(2*A*dx+v0*v0));
}double ans=inf;
For(i,0,m) For(j,0,N-5) if(f[i][j]>=-eps){
double dx=a[i].x,v0=f[i][j],t1=j/2*(a[i].g+a[i].r)+(j&1)*a[i].r;bool flg=1;
For(k,i+1,m){
double dx=a[k].x-a[i].x;
double nt=t1+solve(A/2,v0,-dx);
double rst=nt-(int)(nt/(a[k].g+a[k].r))*(a[k].g+a[k].r);
if(rst<a[k].r-eps){flg=0;break;}
}if(flg) ans=min(ans,t1+solve(A/2,v0,-(X-a[i].x)));
}printf("%.3lf\n",ans);
}
signed LJY(){while(scanf("%lf%d",&X,&m)==2) ljy();}
详细
Pretests
Final Tests
Test #1:
score: 0
Time Limit Exceeded
input:
410.0 2 200.0 15.0 15.0 225.0 31.0 10.0 410.0 2 200.0 15.0 15.0 225.0 35.1 15.0 410.0 2 200.0 15.0 15.0 225.0 45.0 10.0 123.4 0 1234.5 0 1001.0 1 100.0 19.652502 10.581152 1002.0 1 800.0 20.98416 10.923976 1003.0 1 100.0 25.0 15.0 1005.0 1 500.0 60.0 15.0 1000.0 1 500.0 22.0 22.0 1103.0 10 101.234 1...