1 条题解
-
0
您需要输出一行结果,你将采取最优的杀敌顺序,当你胜利的时候,此时还可以抵挡 t 次攻击,这时候需要您输出"Win! I still have t.", t为一个整数。或者,你被消灭了,这时候你需要输出 "Game over!"。(输出不含引号)。 Win! I still have t. Win! I still have t. Win! I still have t. 因为这个点卡我十分钟可恶!!!
本题拿BFS+优先队列提前击杀最近的即可解决 ll t[505][505]; ll ans[505][505]; ll vis[505][505]; ll dx[4]={0,0,1,-1}; ll dy[4]={1,-1,0,0}; void solve() { int q,n,x0,y0,didang; cin>>q>>n>>x0>>y0>>didang; vec<pll>a(q); Fo(i,0,q) { int x,y; cin>>x>>y; a[i]=make_pair(x,y); } For(i,1,n) For(j,1,n) cin>>t[i][j]; queue<pll>dl; ans[x0][y0]=0; vis[x0][y0]=1; dl.p(make_pair(x0,y0)); while(!dl.empty()) { ll dqx,dqy; dqx=dl.front().first;dqy=dl.front().second; dl.pop(); Fo(i,0,4) { if((dqx+dx[i]>=1&&dqx+dx[i]<=n)&&(dqy+dy[i]>=1&&dqy+dy[i]<=n)&&vis[dqx+dx[i]][dqy+dy[i]]==0&&t[dqx+dx[i]][dqy+dy[i]]==0) { dl.p(make_pair(dqx+dx[i],dqy+dy[i])); ans[dqx+dx[i]][dqy+dy[i]]=ans[dqx][dqy]+1; vis[dqx+dx[i]][dqy+dy[i]]=1; } } } priority_queue<ll,vec<ll>,greater<>>pq; Fo(i,0,q) { pq.p(ans[a[i].first][a[i].second]); //cout<<a[i].first<<' '<<a[i].second<<' '<<ans[a[i].first][a[i].second]<<'\n'; } int qj=0; Fo(i,0,q) { if(pq.top()-qj>0) { pq.pop(); qj++; } else if(didang>=0) { didang-=((pq.top()-qj)+1); pq.pop(); qj++; } else { cout<<"Game over!"; return; } } if(didang>=0) cout<<"Win! I still have "<<didang<<'.'; else cout<<"Game over!"; return; } int main() { AC; int t=1; //cin>>t; while(t--){solve();} return 0; }
信息
- ID
- 868
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 40
- 已通过
- 6
- 上传者