結果
| 問題 |
No.20 砂漠のオアシス
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-24 22:11:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,164 bytes |
| コンパイル時間 | 479 ms |
| コンパイル使用メモリ | 60,312 KB |
| 最終ジャッジ日時 | 2024-11-14 19:00:17 |
| 合計ジャッジ時間 | 873 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:13: error: ‘tie’ was not declared in this scope
23 | tie(d, r, c)=q.top(); q.pop();
| ^~~
main.cpp:4:1: note: ‘std::tie’ is defined in header ‘<tuple>’; did you forget to ‘#include <tuple>’?
3 | #include <queue>
+++ |+#include <tuple>
4 |
In file included from /usr/include/c++/11/vector:67,
from /usr/include/c++/11/queue:61,
from main.cpp:3:
/usr/include/c++/11/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++/11/bits/stl_vector.h:487:7: required from ‘std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Seq = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Requires = void; _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >]’
main.cpp:19:46: required from here
/usr/include/c++/11/bits/stl_vector.h:336:49: error: invalid use of incomplete type ‘class std::tuple<int, int, int>’
336 | _M_impl._M_end_of_storage - _M_impl._M_start);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/move.h:57,
from /usr/include/c++/11/bits/exception_ptr.h:43,
from /usr/include/c++/11/exception:153,
from /usr/include/c++/11/ios:39,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from main.cpp:1:
/usr/include/c++/11/type_traits:45:11: note: declaration of ‘class std::tuple<int, int, int>’
45 | class tuple;
| ^~~~~
/usr/include/c++/11/type_traits: In substitu
ソースコード
#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) {
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);
}
}
}
n--, ox--, oy--;
if (cost[n][n]<v or (ox>=0 and ox>=0 and 2*(v-cost[oy][ox])>cost[n][n]-cost[oy][ox]))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
hogeover30