結果
問題 | No.367 ナイトの転身 |
ユーザー | sio_puyo |
提出日時 | 2016-04-30 00:48:29 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,066 bytes |
コンパイル時間 | 1,766 ms |
コンパイル使用メモリ | 175,916 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-15 07:58:54 |
合計ジャッジ時間 | 4,560 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 362 ms
6,940 KB |
testcase_11 | AC | 555 ms
6,944 KB |
testcase_12 | AC | 237 ms
6,940 KB |
testcase_13 | AC | 217 ms
6,940 KB |
testcase_14 | AC | 219 ms
6,940 KB |
testcase_15 | AC | 8 ms
6,940 KB |
testcase_16 | AC | 192 ms
6,940 KB |
testcase_17 | AC | 23 ms
6,944 KB |
testcase_18 | AC | 32 ms
6,940 KB |
testcase_19 | AC | 60 ms
6,940 KB |
testcase_20 | AC | 27 ms
6,944 KB |
testcase_21 | AC | 56 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 4 ms
6,940 KB |
testcase_24 | AC | 5 ms
6,944 KB |
testcase_25 | AC | 4 ms
6,944 KB |
testcase_26 | AC | 3 ms
6,944 KB |
ソースコード
#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; }