結果

問題 No.20 砂漠のオアシス
ユーザー BantakoBantako
提出日時 2018-12-30 17:54:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 369 ms / 5,000 ms
コード長 1,016 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 164,352 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 21:49:02
合計ジャッジ時間 3,191 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 6 ms
6,944 KB
testcase_05 AC 9 ms
6,940 KB
testcase_06 AC 13 ms
6,940 KB
testcase_07 AC 369 ms
6,940 KB
testcase_08 AC 60 ms
6,944 KB
testcase_09 AC 188 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 5 ms
6,944 KB
testcase_13 AC 5 ms
6,944 KB
testcase_14 AC 17 ms
6,944 KB
testcase_15 AC 9 ms
6,944 KB
testcase_16 AC 35 ms
6,940 KB
testcase_17 AC 15 ms
6,944 KB
testcase_18 AC 31 ms
6,940 KB
testcase_19 AC 30 ms
6,940 KB
testcase_20 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:23:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int N,V,X,Y;
int table[200][200];
int rest[200][200];
void dfs(int y, int x, int v){
    if(v <= 0)return;
    int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
    rep(i,0,4){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx < 0 || nx >= N || ny < 0 || ny >= N)continue;
        if(rest[ny][nx] < v - table[ny][nx]){
            rest[ny][nx] = v - table[ny][nx];
            dfs(ny, nx, rest[ny][nx]);
        }
    }
}
main(){
    cin >> N >> V >> X >> Y;
    
    rep(i,0,N)rep(j,0,N){
        cin >> table[i][j];
        rest[i][j] = 0;
    }
    dfs(0, 0, V);
    //if(X != 0 || Y != 0)cout << rest[Y-1][X-1] << endl;
    if(X != 0 || Y != 0){
        dfs(Y-1, X-1, rest[Y-1][X-1] * 2);
    }
    //if(X != 0 || Y != 0)cout << rest[Y-1][X-1] << endl;
    string ans[] = {"NO", "YES"};
    cout << ans[rest[N-1][N-1] > 0] << endl;
}
0