結果
| 問題 |
No.17 2つの地点に泊まりたい
|
| コンテスト | |
| ユーザー |
plasma_e
|
| 提出日時 | 2019-01-17 21:23:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,190 bytes |
| コンパイル時間 | 610 ms |
| コンパイル使用メモリ | 83,680 KB |
| 最終ジャッジ日時 | 2025-01-06 20:29:30 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:26: error: ‘int64_t’ is not a member of ‘std’; did you mean ‘int64_t’?
12 | std::vector<std::int64_t> cost(N);
| ^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:155,
from /usr/include/stdlib.h:514,
from /usr/include/c++/13/cstdlib:79,
from /usr/include/c++/13/ext/string_conversions.h:43,
from /usr/include/c++/13/bits/basic_string.h:4109,
from /usr/include/c++/13/string:54,
from /usr/include/c++/13/bits/locale_classes.h:40,
from /usr/include/c++/13/bits/ios_base.h:41,
from /usr/include/c++/13/ios:44,
from /usr/include/c++/13/ostream:40,
from /usr/include/c++/13/iostream:41,
from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: ‘int64_t’ declared here
27 | typedef __int64_t int64_t;
| ^~~~~~~
main.cpp:12:33: error: template argument 1 is invalid
12 | std::vector<std::int64_t> cost(N);
| ^
main.cpp:12:33: error: template argument 2 is invalid
main.cpp:13:24: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
13 | for (auto& c : cost)
| ^~~~
| std::begin
In file included from /usr/include/c++/13/string:53:
/usr/include/c++/13/bits/range_access.h:114:37: note: ‘std::begin’ declared here
114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
| ^~~~~
main.cpp:13:24: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
13 | for (auto& c : cost)
| ^~~~
| std::end
/usr/include/c++/13/bits/range_acces
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
int main()
{
int N;
std::cin >> N;
std::vector<std::int64_t> cost(N);
for (auto& c : cost)
{
std::cin >> c;
}
std::vector<std::map<int, std::int64_t>> edge(N);
int M;
std::cin >> M;
for (int i = 0; i < M; ++i)
{
int A, B;
std::int64_t C;
std::cin >> A >> B >> C;
edge[A][B] = C;
edge[B][A] = C;
}
std::int64_t ecost[50][50];
for (int i = 0; i < N; ++i)
{
for (int k = 0; k < N; ++k)
{
ecost[i][k] = std::numeric_limits<int>::max();
if (edge[i].count(k))
{
ecost[i][k] = edge[i][k];
}
}
}
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
for (int k = 0; k < N; ++k)
{
ecost[j][k] = std::min(ecost[j][k], ecost[j][i] + ecost[i][k]);
}
}
}
std::int64_t min = std::numeric_limits<int>::max();
for (int i = 1; i < N - 1; ++i)
{
for (int k = 1; k < N - 1; ++k)
{
if (i == k)
{
continue;
}
min = std::min(min,
cost[i] + cost[k] + ecost[0][i] + ecost[i][k] + ecost[k][N - 1]);
}
}
std::cout << min << std::endl;
}
plasma_e