結果

問題 No.20 砂漠のオアシス
ユーザー BantakoBantako
提出日時 2018-12-30 17:54:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 374 ms / 5,000 ms
コード長 1,016 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 169,784 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-08 02:30:24
合計ジャッジ時間 3,344 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
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