| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 39908 | LYLAKIOIAKIOI | 【BJ】T1 | C++ | 解答错误 | 39 | 312 MS | 1900 KB | 3419 | 2026-02-06 19:16:46 |
#include<bits/stdc++.h> #define double long double using namespace std; const int N=25; const double g=9.80665,pi=acos(-1); double h[N][N]; int n,m,s,t;double w,v; bool check(double dx,double dy,double v,double vd){ double vh=sqrtl(v*v-vd*vd),t=dx/vd; //cout<<dx<<' '<<dy<<' '<<v<<' '<<vd<<' '<<vh<<' '<<t<<endl; if(fabs(vh*t-g*t*t/2-dy)<1e-8) return 1; return 0; } double get(double dx,double dy,double v){ double A=dx*dx+dy*dy,C=g*g*dx*dx*dx*dx/4,B=g*dx*dx*dy-v*v*dx*dx; double D=B*B-4*A*C; if(D<0) return v+1; double w1=(-B+sqrtl(D))/(A*2),w2=(-B-sqrtl(D))/(A*2); double res=v+1; if(w1>0)if(sqrtl(w1)<=v)if(check(dx,dy,v,sqrtl(w1))) res=min(res,sqrtl(w1)); if(w2>0)if(sqrtl(w2)<=v)if(check(dx,dy,v,sqrtl(w2))) res=min(res,sqrtl(w2)); return res; } double dist(double x,double y){ return sqrtl(x*x+y*y); } double geth(double vh,double t){ return vh*t-g*t*t/2; } double TO(double l,double r,double v){ return min(r,max(l,v)); } bool chk(int A,int B,int C,int D){ double dis=dist((A-C)*w,(B-D)*w); double vd=get(dis,h[C][D]-h[A][B],v); if(vd>v) return 0; double vh=sqrtl(v*v-vd*vd); //cout<<A<<' '<<B<<' '<<C<<' '<<D<<' '<<vd<<' '<<vh<<endl; //cout<<(vh*(dis/vd)-g*(dis*dis/vd/vd)/2)<<endl; double sx=(A<=C)?1:(-1),sy=(B<=D)?1:(-1); double vx=vd/dis*(C-A)*w,vy=vd/dis*(D-B)*w; for(int i=min(A,C);i<=max(A,C);i++){ for(int j=min(B,D);j<=max(B,D);j++){ double mn=TO(0,dis/vd,max(((i-A)*w-sx*w/2)/vx,((j-B)*w-sy*w/2)/vy)); double mx=TO(0,dis/vd,min(((i-A)*w+sx*w/2)/vx,((j-B)*w+sy*w/2)/vy)); if(mn>mx) swap(mn,mx); if(mn<=mx){ //cout<<A<<' '<<B<<' '<<C<<' '<<D<<' '<<i<<' '<<j<<' '<<min(geth(vh,mn),geth(vh,mx))+h[A][B]<<endl; if(min(geth(vh,mn),geth(vh,mx))+h[A][B]<h[i][j]-1e-8){ //cout<<A<<' '<<B<<' '<<C<<' '<<D<<' '<<i<<' '<<j<<' '<<min(geth(vh,mn),geth(vh,mx))+h[A][B]<<' '<<h[i][j]<<endl; return 0; } } } } //cout<<A<<' '<<B<<' '<<C<<' '<<D<<endl; return 1; } vector<pair<int,int>> E[N][N]; int d[N][N]; int main(){ //freopen("crime.in","r",stdin); //freopen("crime.out","w",stdout); cin>>m>>n>>w>>v>>t>>s; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>h[i][j]; } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ for(int x=1;x<=n;x++){ for(int y=1;y<=m;y++){ if(i==x&&j==y) continue; if(chk(i,j,x,y)) E[i][j].emplace_back(x,y); } } } } memset(d,0x3f,sizeof(d)); queue<pair<int,int>> q;q.emplace(s,t);d[s][t]=0; while(!q.empty()){ pair<int,int> p=q.front();q.pop(); int x=p.first,y=p.second; for(auto ed:E[x][y]){ int nx=ed.first,ny=ed.second; if(d[x][y]+1<d[nx][ny]){ d[nx][ny]=d[x][y]+1; q.emplace(nx,ny); } } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(d[i][j]>=(int)(1e9)){ cout<<'X'; }else{ cout<<d[i][j]; }cout<<' '; }cout<<'\n'; } return 0; }