結果
問題 | No.367 ナイトの転身 |
ユーザー | sio_puyo |
提出日時 | 2016-04-30 00:20:37 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,033 bytes |
コンパイル時間 | 2,278 ms |
コンパイル使用メモリ | 171,576 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-15 07:54:53 |
合計ジャッジ時間 | 3,475 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
ソースコード
#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]; REP(i,h) REP(j,w) if(fi[i][j]=='S') cost[i][j][0]=0; priority_queue<tuple<int,int,int,int> > dijk; // 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; cost[x][y][t]=max(cost[x][y][t],negc); if(fi[x][y]=='R') t=1-t; if(t) REP(i,8) dijk.push(make_tuple(negc-1,x+dx[i+4],y+dy[i+4],t)); else REP(i,4) dijk.push(make_tuple(negc-1,x+dx[i],y+dy[i],t)); } REP(i,h) REP(j,w) if(fi[i][j]=='G')cout << min(cost[i][j][0],cost[i][j][1]) << endl; return 0; }