結果
| 問題 | No.34 砂漠の行商人 | 
| コンテスト | |
| ユーザー |  moti | 
| 提出日時 | 2015-07-16 02:12:04 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                CE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,171 bytes | 
| コンパイル時間 | 503 ms | 
| コンパイル使用メモリ | 74,596 KB | 
| 最終ジャッジ日時 | 2024-11-14 19:06:08 | 
| 合計ジャッジ時間 | 930 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:26:11: error: ‘inrange’ function uses ‘auto’ type specifier without trailing return type
   26 | constexpr auto inrange(int x, int y) { return 0<=x&&x<N && 0<=y&&y<N; }
      |           ^~~~
main.cpp:26:11: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’
main.cpp:27:29: error: ‘chmax’ function uses ‘auto’ type specifier without trailing return type
   27 | template<class T> constexpr auto chmax(T& x, T a) { x = max(x, a); }
      |                             ^~~~
main.cpp:27:29: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’
            
            ソースコード
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
int N, V;
int sx, sy, gx, gy;
int dp[2][101][101];
int L[101][101];
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
constexpr auto inrange(int x, int y) { return 0<=x&&x<N && 0<=y&&y<N; }
template<class T> constexpr auto chmax(T& x, T a) { x = max(x, a); }
int main() {
  cin >> N >> V >> sx >> sy >> gx >> gy;
  --sx, --sy, --gx, --gy;
  rep(i, N) rep(j, N) {
    cin >> L[i][j];
  }
  int constexpr MaxStep = 11111;
  dp[0][sy][sx] = V;
  rep(step, MaxStep) {
    auto curr = dp[step&1], next = dp[(step+1)&1];
    if(curr[gy][gx] > 0) { cout << step << endl; return 0; }
    rep(y, N) rep(x, N) { next[y][x] = 0; }
    rep(y, N) rep(x, N) {
      rep(k, 4) {
        int nx = x+dx[k], ny = y+dy[k];
        if(!inrange(nx, ny)) { continue; }
        if(curr[y][x] <= L[ny][nx]) { continue; }
        chmax(next[ny][nx], curr[y][x] - L[ny][nx]);
      }
    }
  }
  cout << -1 << endl;
  return 0;
}
            
            
            
        