結果
| 問題 | No.3599 Queen Moving Query |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-24 22:06:20 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,307 bytes |
| 記録 | |
| コンパイル時間 | 1,402 ms |
| コンパイル使用メモリ | 198,668 KB |
| 実行使用メモリ | 21,760 KB |
| 最終ジャッジ日時 | 2026-07-24 22:06:27 |
| 合計ジャッジ時間 | 6,584 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 WA * 7 |
ソースコード
#include <iostream>
#include <deque>
#include <string>
#include <ranges>
#include <algorithm>
#include <vector>
using namespace std;
using ll=long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int h,w;
cin>>h>>w;
int sx,sy;
cin>>sx>>sy;
sx--;sy--;
vector<string> s(h);
for(int i=0;i<h;i++)cin>>s[i];
vector<int> dx={1,0,-1,0,1,1,-1,-1},dy={0,1,0,-1,1,-1,1,-1};
vector dist(17,vector(h,vector<int>(w,2e9)));
dist[0][sx][sy]=0;
deque<array<int,4>> deq;
deq.push_back({0,0,sx,sy});
while(!deq.empty()){
auto[d,c,x,y]=deq.front();
deq.pop_front();
if(d>dist[c][x][y])continue;
for(int r=0;r<8;r++){
int nx=x+dx[r],ny=y+dy[r];
if(nx<0||nx>=h||ny<0||ny>=w||s[nx][ny]=='#')continue;
int w=0;
if(c==0||(c-1)%8!=r)w=1;
int nc;
if(c>=9)nc=9+r;
else if(c==0)nc=1+r;
else if(c-1==r)nc=9+r;
else nc=1+r;
if(dist[nc][nx][ny]<=d+w)continue;
dist[nc][nx][ny]=d+w;
if(w==0)deq.push_front({d,nc,nx,ny});
else deq.push_back({d+1,nc,nx,ny});
}
}
int q;
cin>>q;
while(q--){
int gx,gy,t;
cin>>gx>>gy>>t;
gx--;gy--;
bool ok=false;
for(int i=1;i<16;i++){
if(i<=8&&dist[i][gx][gy]<=t&&(t-dist[i][gx][gy])%2==0)ok=true;
if(i>=9&&dist[i][gx][gy]<=t)ok=true;
}
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}