結果
問題 | No.20 砂漠のオアシス |
ユーザー | ryosuke000010 |
提出日時 | 2018-05-18 13:38:02 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,505 bytes |
コンパイル時間 | 846 ms |
コンパイル使用メモリ | 71,020 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-10 22:51:48 |
合計ジャッジ時間 | 2,473 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | WA | - |
testcase_02 | AC | 1 ms
4,384 KB |
testcase_03 | AC | 3 ms
4,380 KB |
testcase_04 | AC | 3 ms
4,384 KB |
testcase_05 | WA | - |
testcase_06 | AC | 20 ms
4,384 KB |
testcase_07 | WA | - |
testcase_08 | AC | 20 ms
4,384 KB |
testcase_09 | AC | 20 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,384 KB |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
4,384 KB |
testcase_13 | AC | 2 ms
4,384 KB |
testcase_14 | AC | 3 ms
4,380 KB |
testcase_15 | AC | 3 ms
4,384 KB |
testcase_16 | AC | 5 ms
4,384 KB |
testcase_17 | AC | 4 ms
4,384 KB |
testcase_18 | WA | - |
testcase_19 | AC | 5 ms
4,380 KB |
testcase_20 | AC | 2 ms
4,384 KB |
ソースコード
#include <iostream> #include <queue> #include <algorithm> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) const int INF = 1e8; int N, V, Ox, Oy,ny,nx,c; typedef long long ll; typedef pair<int, int> P; typedef pair<int, P> PP; int dy[]={0,1,-1,0}; int dx[]={1,0,-1,0}; int cost[210][210]; int dist[210][210]; pair<int,int> now; void dijkstra(int y,int x) { rep(i,N)rep(j,N)dist[i][j] = INF; priority_queue<PP, vector<PP>, greater<PP> > que; que.push(make_pair(0, make_pair(y, x))); dist[y][x]=0; while(!que.empty()) { c = que.top().first; now = que.top().second; que.pop(); rep(i,4) { ny=now.first+dy[i], nx=now.second+dx[i]; if(!(0 <= ny && ny < N && 0 <= nx && nx < N)) continue; if(dist[ny][nx] <= c + cost[ny][nx]) continue; dist[ny][nx] = c + cost[ny][nx]; que.push(make_pair(dist[ny][nx],make_pair(ny,nx))); } } } int main() { cin >> N >> V >> Ox >> Oy; Ox--; Oy--; rep(i,N) { rep(j,N) { cin >> cost[i][j]; } } dijkstra(0,0); if(dist[N-1][N-1]<V) { cout << "YES" << endl; return 0; } if(Ox == -1 && Oy == -1){ cout << "NO" << endl; return 0; } int t = (V - dist[Oy][Ox]) * 2; dijkstra(Oy, Ox); if(t - dist[N - 1][N - 1] > 0){ cout << "YES" << endl; }else{ cout << "NO" << endl; } return 0; }