結果
問題 | No.20 砂漠のオアシス |
ユーザー | chocorusk |
提出日時 | 2018-10-17 04:54:44 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1,059 ms / 5,000 ms |
コード長 | 1,234 bytes |
コンパイル時間 | 806 ms |
コンパイル使用メモリ | 90,848 KB |
実行使用メモリ | 66,304 KB |
最終ジャッジ日時 | 2024-04-20 20:43:20 |
合計ジャッジ時間 | 3,934 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 7 ms
6,016 KB |
testcase_04 | AC | 22 ms
8,576 KB |
testcase_05 | AC | 78 ms
63,872 KB |
testcase_06 | AC | 30 ms
9,984 KB |
testcase_07 | AC | 1,059 ms
66,304 KB |
testcase_08 | AC | 135 ms
19,840 KB |
testcase_09 | AC | 613 ms
57,728 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 14 ms
6,656 KB |
testcase_13 | AC | 13 ms
6,144 KB |
testcase_14 | AC | 63 ms
11,392 KB |
testcase_15 | AC | 34 ms
9,088 KB |
testcase_16 | AC | 115 ms
18,560 KB |
testcase_17 | AC | 60 ms
13,824 KB |
testcase_18 | AC | 97 ms
15,744 KB |
testcase_19 | AC | 100 ms
18,048 KB |
testcase_20 | AC | 7 ms
5,376 KB |
ソースコード
#include <cstdio> #include <cstring> #include <string> #include <iostream> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <unordered_map> #include <unordered_set> #include <random> using namespace std; typedef long long int ll; typedef pair<int, int> P; int n, v, ox, oy; bool used[2][201][201][1001]; int l[201][201]; int dx[4]={1, -1, 0, 0}, dy[4]={0, 0, 1, -1}; void dfs(int i, int x, int y, int w){ used[i][x][y][w]=1; for(int k=0; k<4; k++){ if(0<x+dx[k] && x+dx[k]<=n && 0<y+dy[k] && y+dy[k]<=n && w>l[x+dx[k]][y+dy[k]]){ if(!used[i][x+dx[k]][y+dy[k]][w-l[x+dx[k]][y+dy[k]]]) dfs(i, x+dx[k], y+dy[k], w-l[x+dx[k]][y+dy[k]]); if(i==0 && x+dx[k]==ox && y+dy[k]==oy){ if(!used[i+1][x+dx[k]][y+dy[k]][2*(w-l[x+dx[k]][y+dy[k]])]) dfs(i+1, x+dx[k], y+dy[k], 2*(w-l[x+dx[k]][y+dy[k]])); } } } } int main() { cin>>n>>v>>ox>>oy; for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) cin>>l[j][i]; dfs(0, 1, 1, v); bool ok=0; for(int i=0; i<2; i++){ for(int j=1; j<=2*v; j++){ if(used[i][n][n][j]){ ok=1; break; } } if(ok) break; } if(ok) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }