結果

問題 No.20 砂漠のオアシス
ユーザー EmKjpEmKjp
提出日時 2015-02-21 19:38:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,776 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 85,708 KB
実行使用メモリ 90,824 KB
最終ジャッジ日時 2024-04-21 06:23:42
合計ジャッジ時間 5,413 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
83,340 KB
testcase_01 AC 37 ms
83,356 KB
testcase_02 AC 36 ms
83,340 KB
testcase_03 WA -
testcase_04 AC 58 ms
83,792 KB
testcase_05 WA -
testcase_06 AC 58 ms
83,820 KB
testcase_07 WA -
testcase_08 AC 201 ms
84,988 KB
testcase_09 AC 744 ms
88,280 KB
testcase_10 AC 38 ms
83,356 KB
testcase_11 WA -
testcase_12 AC 49 ms
83,664 KB
testcase_13 AC 54 ms
83,980 KB
testcase_14 AC 123 ms
84,392 KB
testcase_15 AC 82 ms
84,080 KB
testcase_16 AC 185 ms
85,016 KB
testcase_17 AC 113 ms
84,420 KB
testcase_18 AC 169 ms
84,952 KB
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:52:68: warning: use of an operand of type ‘bool’ in ‘operator++’ is deprecated [-Wdeprecated]
   52 |         if(visited[now.row][now.col][now.vitality][now.visitedOasis]++) continue;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
main.cpp:43:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |     FOR(i,N) FOR(j,N) scanf("%d", &L[i][j]);
      |                       ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<numeric>
#include<functional>
#include<complex>

using namespace std;
#define BET(a,b,c) ((a)<=(b)&&(b)<(c))
#define FOR(i,n) for(int i=0,i##_end=(int(n));i<i##_end;i++)
#define SZ(x) (int)(x.size())
#define ALL(x) (x).begin(),(x).end()
#define MP make_pair
#define FOR_EACH(it,v) for(__typeof(v.begin()) it=v.begin(),it_end=v.end() ; it != it_end ; it++)
typedef vector<int> VI;
typedef vector<VI> VVI;

int L[222][222];

struct data{
    int row, col;
    int vitality;
    bool visitedOasis;
};

bool visited[202][202][1002][2];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

int main()
{
    int N,V,ox,oy;
    cin>>N>>V>>ox>>oy;
    FOR(i,N) FOR(j,N) scanf("%d", &L[i][j]);
    queue<data> qu;
    qu.push((data){ 0, 0, V, false});
    memset(visited , 0 , sizeof(visited));
    while(!qu.empty()){
        data now = qu.front(); qu.pop();
        if(now.row == oy && now.col == ox && !now.visitedOasis){
            qu.push((data){now.row,now.col,2*now.vitality,true});
        }
        if(visited[now.row][now.col][now.vitality][now.visitedOasis]++) continue;
        if(now.row == N - 1 && now.col == N - 1){
            puts("YES");
            return 0;
        }
        FOR(i,4){
            int nr = now.row + dy[i];
            int nc = now.col + dx[i];
            if(BET(0,nr,N) && BET(0,nc,N)){
                int nv = now.vitality;
                nv -= L[nr][nc];
                if(nv > 0){
                    qu.push((data){nr, nc, nv, now.visitedOasis});
                }
            }
        }
    }
    puts("NO");
    
    return 0;
}
0