結果
| 問題 | No.3599 Queen Moving Query |
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2026-07-24 21:45:08 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,034 bytes |
| 記録 | |
| コンパイル時間 | 1,289 ms |
| コンパイル使用メモリ | 219,792 KB |
| 実行使用メモリ | 6,656 KB |
| 最終ジャッジ日時 | 2026-07-24 21:45:24 |
| 合計ジャッジ時間 | 15,732 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 TLE * 1 -- * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=200005,INF=15<<26;
ll dis[2][MAX];
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
ll H,W,sh,sw;cin>>H>>W>>sh>>sw;sh--;sw--;
vst S(H);
for(int i=0;i<H;i++){
cin>>S[i];
}
for(int q=0;q<2;q++){
for(int i=0;i<H*W;i++){
dis[q][i]=INF;
}
}
queue<pii> Q;
Q.push(mp(0,sh*W+sh));
dis[0][sh*W+sh]=0;
while(!Q.empty()){
auto [t,po]=Q.front();Q.pop();
int h=po/W,w=po%W;
for(int dh=-1;dh<=1;dh++){
for(int dw=-1;dw<=1;dw++){
if(dh==0&&dw==0) continue;
int toh=h,tow=w;
while(1){
toh+=dh;
tow+=dw;
if(toh<0||toh>=H||tow<0||tow>=W||S[toh][tow]=='#'||dis[t^1][toh*W+tow]<dis[t][po]+1) break;
if(chmin(dis[t^1][toh*W+tow],dis[t][po]+1)) Q.push(mp(t^1,toh*W+tow));
}
}
}
}
int QQ;cin>>QQ;
while(QQ--){
int h,w,t;cin>>h>>w>>t;
h--;w--;
if(dis[t&1][h*W+w]<=t) cout<<"Yes\n";
else cout<<"No\n";
}
}
Rubikun