結果
| 問題 | No.20 砂漠のオアシス | 
| コンテスト | |
| ユーザー |  tkmst201 | 
| 提出日時 | 2017-05-18 19:59:36 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,474 bytes | 
| コンパイル時間 | 1,293 ms | 
| コンパイル使用メモリ | 165,368 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-13 05:51:11 | 
| 合計ジャッジ時間 | 2,229 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 WA * 2 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |         REP(i, n) REP(j, n) scanf("%d", &l[i][j]);
      |                             ~~~~~^~~~~~~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
int n, v, ox, oy;
int l[200][200];
int dp[200][200][2];
int main() {
	cin >> n >> v >> ox >> oy;
	REP(i, n) REP(j, n) scanf("%d", &l[i][j]);
	ox--; oy--;
	
	memset(dp, -1, sizeof(dp));
	
	priority_queue<P> pq;
	pq.push(P(pii(v, 1), pii(0, 0)));
	
	while (!pq.empty()) {
		P now = pq.top(); pq.pop();
		
		int h = now.first.first;
		int f = now.first.second;
		
		int x = now.second.first;
		int y = now.second.second;
		
		if (!chmax(dp[y][x][f], h)) continue;
		
		static int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
		
		REP(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			
			if (!(nx >= 0 && nx < n && ny >= 0 && ny < n)) continue;
			
			pq.push(P(pii(h - l[ny][nx], f), pii(nx, ny)));
			if (f && nx == ox && ny == oy) pq.push(P(pii((h - l[ny][nx]) * 2, 0), pii(nx, ny)));
		}
	}
	
	if (~dp[n - 1][n - 1][0] || ~dp[n - 1][n - 1][1]) puts("YES");
	else puts("NO");
	
	return 0;
}
            
            
            
        