結果
| 問題 |
No.367 ナイトの転身
|
| コンテスト | |
| ユーザー |
sio_puyo
|
| 提出日時 | 2016-04-30 00:48:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,066 bytes |
| コンパイル時間 | 1,316 ms |
| コンパイル使用メモリ | 174,972 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-04 23:42:01 |
| 合計ジャッジ時間 | 4,103 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 WA * 4 |
ソースコード
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int cost[512][512][2];
int h,w;
vector<string> fi;
int main(void)
{
cin >> h >> w;
REP(i,h) REP(j,w) REP(k,2) cost[i][j][k]=-1048576;
int dx[12]={1,1,-1,-1,1,1,2,2,-1,-1,-2,-2};
int dy[12]={1,-1,-1,1,2,-2,1,-1,2,-2,1,-1};
fi.resize(h);
REP(i,h) cin >> fi[i];
priority_queue<tuple<int,int,int,int> > dijk;
REP(i,h) REP(j,w) if(fi[i][j]=='S') dijk.push(make_tuple(0,i,j,0));
// negcos,x,y,type;
while(!dijk.empty()){
int negc,x,y,t;
tie(negc,x,y,t)=dijk.top();
dijk.pop();
if(x<0||h<=x||y<0||w<=y) continue;
if(cost[x][y][t]>=negc) continue;
cost[x][y][t]=negc;
if(fi[x][y]=='R') t=1-t;
if(t) REP(i,4) dijk.push(make_tuple(negc-1,x+dx[i],y+dy[i],t));
else REP(i,8) dijk.push(make_tuple(negc-1,x+dx[i+4],y+dy[i+4],t));
}
REP(i,h) REP(j,w) if(fi[i][j]=='G')cout << -max(cost[i][j][0],cost[i][j][1]) << endl;
return 0;
}
sio_puyo