結果
| 問題 | No.20 砂漠のオアシス |
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-05-18 13:38:01 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,393 bytes |
| 記録 | |
| コンパイル時間 | 511 ms |
| コンパイル使用メモリ | 78,812 KB |
| 最終ジャッジ日時 | 2026-04-30 13:11:35 |
| 合計ジャッジ時間 | 3,819 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:23:12: error: 'make_tuple' was not declared in this scope
23 | q.push(make_tuple(v,1,1,0));
| ^~~~~~~~~~
main.cpp:6:1: note: 'std::make_tuple' is defined in header '<tuple>'; this is probably fixable by adding '#include <tuple>'
5 | #include <iomanip>
+++ |+#include <tuple>
6 | using namespace std;
main.cpp:26:23: error: no matching function for call to 'get<1>(const __gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int, bool> >, std::tuple<int, int, int, bool> >::value_type&)'
26 | int y = get<1>(q.top());
| ~~~~~~^~~~~~~~~
main.cpp:26:23: note: there are 12 candidates
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:64,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:53,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_pair.h:1283:5: note: candidate 1: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1283 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_pair.h:1283:5: note: template argument deduction/substitu
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
using namespace std;
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,(int)(n)-1,0)
#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP(i,0,(int)(n)-1)
#define INF 100000000
typedef long long ll;
int main() {
int i, j, n, v, ox, oy;
int l[201][201];
int hp[2][201][201] {};
priority_queue<tuple<int,int,int,bool>> q; // (hp,x,y,oasis)
cin >> n >> v >> ox >> oy;
REP (i,1,n) REP (j,1,n) cin >> l[i][j];
q.push(make_tuple(v,1,1,0));
hp[0][1][1] = v;
while (!q.empty()) {
int y = get<1>(q.top());
int x = get<2>(q.top());
bool oasis = get<3>(q.top());
q.pop();
int dxy[4] = {-1,0,1,0};
rep (i,4) {
int nx = x + dxy[i];
int ny = y + dxy[(i+1)%4];
if (nx < 1 || nx > n || ny < 1 || ny > n)
continue;
bool noasis = oasis || nx == ox && ny == oy;
int nhp = (hp[oasis][y][x] - l[ny][nx]) * (noasis != oasis ? 2 : 1);
if (hp[noasis][ny][nx] < nhp) {
hp[noasis][ny][nx] = nhp;
q.push(make_tuple(nhp,ny,nx,noasis));
}
}
}
if (hp[0][n][n] || hp[1][n][n])
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
h_noson