結果
問題 | No.20 砂漠のオアシス |
ユーザー | hogeover30 |
提出日時 | 2015-02-24 21:57:30 |
言語 | C++11 (gcc 11.4.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,167 bytes |
コンパイル時間 | 361 ms |
コンパイル使用メモリ | 58,816 KB |
最終ジャッジ日時 | 2023-08-03 07:27:36 |
合計ジャッジ時間 | 683 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:24:13: error: ‘tie’ was not declared in this scope tie(d, r, c)=q.top(); q.pop(); ^~~ main.cpp:24:13: note: suggested alternative: ‘time’ tie(d, r, c)=q.top(); q.pop(); ^~~ time In file included from /usr/include/c++/8/vector:64, from /usr/include/c++/8/queue:61, from main.cpp:3: /usr/include/c++/8/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]’: /usr/include/c++/8/bits/stl_vector.h:570:7: required from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]’ /usr/include/c++/8/bits/stl_queue.h:435:11: required from here /usr/include/c++/8/bits/stl_vector.h:286:35: error: invalid use of incomplete type ‘class std::tuple<int, int, int>’ _M_impl._M_end_of_storage - _M_impl._M_start); ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/8/bits/move.h:55, from /usr/include/c++/8/bits/nested_exception.h:40, from /usr/include/c++/8/exception:144, from /usr/include/c++/8/ios:39, from /usr/include/c++/8/ostream:38, from /usr/include/c++/8/iostream:39, from main.cpp:1: /usr/include/c++/8/type_traits:2371:11: note: declaration of ‘class std::tuple<int, int, int>’ class tuple; ^~~~~ In file included from /usr/include/c++/8/vector:69, from /usr/include/c++/8/queue:61, from main.cpp:3: /usr/include/c++/8/bits/vector.tcc: In instantiation of ‘void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int, int}; _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int,
ソースコード
#include <iostream> #include <algorithm> #include <queue> using namespace std; const int inf=100000; int cost[210][210], a[210][210]; int dr[]={-1, 0, 1, 0}, dc[]={0, -1, 0, 1}; int main() { int n, v, ox, oy; while (cin>>n>>v>>ox>>oy) { ox--, oy--; for(int i=0;i<n;++i) for(int j=0;j<n;++j) { cin>>a[i][j]; cost[i][j]=100000; } cost[0][0]=a[0][0]; priority_queue<tuple<int, int, int>> q; q.emplace(-cost[0][0], 0, 0); while (q.size()) { int d, r, c; tie(d, r, c)=q.top(); q.pop(); d=-d; if (d>cost[r][c]) continue; for(int i=0;i<4;++i) { int nr=r+dr[i], nc=c+dc[i]; if (nr<0 or nr>=n or nc<0 or nc>=n) continue; if (cost[nr][nc]>d+a[nr][nc]) { cost[nr][nc]=d+a[nr][nc]; q.emplace(-d-a[nr][nc], nr, nc); } } } if (cost[n-1][n-1]<v or (ox>=0 and ox>=0 and 2*(v-cost[oy][ox])>cost[n-1][n-1]-cost[oy][ox])) cout<<"YES"<<endl; else cout<<"NO"<<endl; } }