結果
問題 | No.20 砂漠のオアシス |
ユーザー | chocorusk |
提出日時 | 2018-10-17 04:54:44 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1,040 ms / 5,000 ms |
コード長 | 1,234 bytes |
コンパイル時間 | 703 ms |
コンパイル使用メモリ | 89,608 KB |
実行使用メモリ | 66,180 KB |
最終ジャッジ日時 | 2023-08-02 20:38:17 |
合計ジャッジ時間 | 3,965 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 6 ms
5,808 KB |
testcase_04 | AC | 20 ms
8,632 KB |
testcase_05 | AC | 73 ms
63,948 KB |
testcase_06 | AC | 27 ms
9,912 KB |
testcase_07 | AC | 1,040 ms
66,180 KB |
testcase_08 | AC | 124 ms
19,804 KB |
testcase_09 | AC | 581 ms
57,676 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 13 ms
6,548 KB |
testcase_13 | AC | 13 ms
6,268 KB |
testcase_14 | AC | 60 ms
11,260 KB |
testcase_15 | AC | 31 ms
9,076 KB |
testcase_16 | AC | 106 ms
18,520 KB |
testcase_17 | AC | 55 ms
13,812 KB |
testcase_18 | AC | 88 ms
15,600 KB |
testcase_19 | AC | 92 ms
18,160 KB |
testcase_20 | AC | 6 ms
4,844 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; }