結果
問題 | No.34 砂漠の行商人 |
ユーザー | EmKjp |
提出日時 | 2015-03-02 23:56:58 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1,143 ms / 5,000 ms |
コード長 | 1,684 bytes |
コンパイル時間 | 707 ms |
コンパイル使用メモリ | 81,760 KB |
実行使用メモリ | 108,464 KB |
最終ジャッジ日時 | 2023-09-10 19:06:03 |
合計ジャッジ時間 | 6,957 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
101,196 KB |
testcase_01 | AC | 27 ms
101,148 KB |
testcase_02 | AC | 29 ms
101,332 KB |
testcase_03 | AC | 28 ms
101,036 KB |
testcase_04 | AC | 39 ms
101,720 KB |
testcase_05 | AC | 39 ms
101,440 KB |
testcase_06 | AC | 29 ms
101,076 KB |
testcase_07 | AC | 47 ms
101,512 KB |
testcase_08 | AC | 54 ms
101,592 KB |
testcase_09 | AC | 333 ms
105,468 KB |
testcase_10 | AC | 51 ms
101,928 KB |
testcase_11 | AC | 703 ms
106,936 KB |
testcase_12 | AC | 35 ms
101,876 KB |
testcase_13 | AC | 1,143 ms
108,464 KB |
testcase_14 | AC | 844 ms
107,996 KB |
testcase_15 | AC | 30 ms
101,536 KB |
testcase_16 | AC | 73 ms
102,928 KB |
testcase_17 | AC | 29 ms
101,300 KB |
testcase_18 | AC | 32 ms
101,440 KB |
testcase_19 | AC | 259 ms
106,276 KB |
testcase_20 | AC | 456 ms
108,024 KB |
testcase_21 | AC | 29 ms
101,424 KB |
testcase_22 | AC | 34 ms
101,924 KB |
testcase_23 | AC | 30 ms
101,480 KB |
testcase_24 | AC | 595 ms
107,556 KB |
testcase_25 | AC | 54 ms
102,172 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:49:32: warning: use of an operand of type ‘bool’ in ‘operator++’ is deprecated [-Wdeprecated] if(visited[x][y][vital]++) continue; ^~
ソースコード
#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 dx[] = {0,1,0,-1}; int dy[] = {1,0,-1,0}; bool visited[100][100][10000+1]; int L[111][111]; int main() { int N,V,sx,sy,gx,gy; cin>>N>>V>>sx>>sy>>gx>>gy; sx--; sy--; gx--; gy--; FOR(i,N) FOR(j,N) scanf("%d",&L[i][j]); queue<int> qu; qu.push(sx); qu.push(sy); qu.push(V); qu.push(0); memset(visited , 0 , sizeof(visited)); while(!qu.empty()){ int x = qu.front(); qu.pop(); int y = qu.front(); qu.pop(); int vital = qu.front(); qu.pop(); int step = qu.front(); qu.pop(); if(vital <= 0) continue; if(visited[x][y][vital]++) continue; if(x == gx && y == gy){ cout<<step<<endl; return 0; } FOR(i,4){ int nx = x + dx[i]; int ny = y + dy[i]; if(BET(0,nx,N) && BET(0,ny,N) && vital >= L[ny][nx]){ qu.push(nx); qu.push(ny); qu.push(vital - L[ny][nx]); qu.push(step+1); } } } puts("-1"); return 0; }