結果
問題 | No.867 避難経路 |
ユーザー |
![]() |
提出日時 | 2024-04-14 17:08:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,987 bytes |
コンパイル時間 | 1,169 ms |
コンパイル使用メモリ | 113,608 KB |
最終ジャッジ日時 | 2024-10-03 17:50:49 |
合計ジャッジ時間 | 4,454 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:28:35: error: no matching function for call to 'std::vector<std::tuple<int, int, int, int> >::push_back(<brace-enclosed initializer list>)' 28 | query[min(k, K)].push_back({x, y, k, q}); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64, from main.cpp:2: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:1276:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::tuple<int, int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int, int> >; value_type = std::tuple<int, int, int, int>]' 1276 | push_back(const value_type& __x) | ^~~~~~~~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:1276:35: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::tuple<int, int, int, int> >::value_type&' {aka 'const std::tuple<int, int, int, int>&'} 1276 | push_back(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:1293:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::tuple<int, int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int, int> >; value_type = std::tuple<int, int, int, int>]' 1293 | push_back(value_type&& __x) | ^~~~~~~~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:1293:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::tuple<int, int, int, int> >::value_type&&' {aka 'std::tuple<int, int, int, int>&&'} 1293 | push_back(value_type&& __x) | ~~~~~~~~~~~~~^~~ main.cpp:37:19: error: no matching function
ソースコード
#include <iostream>#include <vector>#include <queue>#include <algorithm>#include <cmath>using namespace std;int main() {int H, W;cin >> H >> W;int gx, gy;cin >> gx >> gy;gx--; gy--;vector<vector<int>> A(H, vector<int>(W));for (int h = 0; h < H; ++h) {for (int w = 0; w < W; ++w) {cin >> A[h][w];}}int Q;cin >> Q;const int K = 251;vector<vector<tuple<int,int,int,int>>> query(K + 1);for (int q = 0; q < Q; ++q) {int x, y, k;cin >> x >> y >> k;x--; y--;query[min(k, K)].push_back({x, y, k, q});}vector<long long> ans_lst(Q);for (int k = 0; k <= K; ++k) {long long w = k < K ? k * k : (1 << 30);long long inf = (1LL << 60);vector<vector<long long>> dist(H, vector<long long>(W, inf));dist[gx][gy] = 0;priority_queue<tuple<long long, int, int>> queue;queue.push({-dist[gx][gy], gx, gy});while (!queue.empty()) {auto [d, x, y] = queue.top();queue.pop();d = -d;for (auto [dx, dy] : vector<pair<int, int>>{{0,1},{1,0},{0,-1},{-1,0}}) {int xx = x + dx, yy = y + dy;if (0 <= xx && xx < H && 0 <= yy && yy < W) {long long dd = d + w + A[xx][yy];if (dist[xx][yy] > dd) {dist[xx][yy] = dd;queue.push({-dd, xx, yy});}}}}for (auto [x, y, c, q] : query[k]) {if (k < K) {ans_lst[q] = dist[x][y] + c * c + A[gx][gy];} else {long long cnt=dist[x][y]/w;long long d=dist[x][y]%w;ans_lst[q] = (cnt + 1) * c * c + d + A[gx][gy];}}}for (int i = 0; i < Q; ++i) {cout << ans_lst[i] << endl;}return 0;}