結果
問題 | No.2708 Jewel holder |
ユーザー |
![]() |
提出日時 | 2024-11-01 20:18:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,284 bytes |
コンパイル時間 | 6,741 ms |
コンパイル使用メモリ | 338,056 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-01 20:18:23 |
合計ジャッジ時間 | 7,839 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; const ll INF=9e18; int main() { ll H,W; cin>>H>>W; vector<string> hai (H); for (ll a = 0; a < H; a++){ cin>>hai[a]; } queue<tuple<ll,ll,ll>>q; q.push({1,0,0}); ll count=0; while(1){ if(q.empty())break; ll jem=get<0>(q.front()); ll x=get<1>(q.front()); ll y=get<2>(q.front()); //cout<<x<<y<<endl; q.pop(); if(x==H-1&&y==W-1){ count++; continue; } //x if(x<H-1){ if(hai[x+1][y]!='#'&&!(hai[x+1][y]=='x'&&jem==0)){ if(hai[x+1][y]=='x'){ q.push({jem-1,x+1,y}); } else{ q.push({jem+1,x+1,y}); } } } if(y<W-1){ if(hai[x][y+1]!='#'&&!(hai[x][y+1]=='x'&&jem==0)){ if(hai[x][y+1]=='x'){ q.push({jem-1,x,y+1}); } else{ q.push({jem+1,x,y+1}); } } } } cout<<count; }