結果
| 問題 |
No.845 最長の切符
|
| コンテスト | |
| ユーザー |
tomarint2
|
| 提出日時 | 2019-06-28 22:30:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,615 bytes |
| コンパイル時間 | 1,055 ms |
| コンパイル使用メモリ | 95,800 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-02 04:55:40 |
| 合計ジャッジ時間 | 2,069 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 11 |
ソースコード
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
void solve()
{
ll N,M,i;
cin >> N >> M;
vector<vector<pll>> to(N);
for1(i,M) {
ll a,b,c;
cin >> a >> b >> c;
--a; --b;
to[a].push_back(make_pair(b,c));
to[b].push_back(make_pair(a,c));
}
//
ll ans = 0;
// 駅iから出発する
for1(i,N) {
vector<ll> score(N,-1);
priority_queue<tuple<ll,ll,ll>> q;
q.push(make_tuple(0,i,0));
while (!q.empty()) {
auto item = q.top();
q.pop();
ll sc = get<0>(item);
ll loc = get<1>(item);
ll arr = get<2>(item);
if (score[loc] >= sc) {
continue;
}
if ((arr & (1LL << loc)) != 0) {
continue;
}
arr |= (1LL << loc);
score[loc] = sc;
for (auto t : to[loc]) {
q.push(make_tuple(sc + t.second, t.first, arr));
}
}
for1(j,N) {
ans = max(ans, score[j]);
}
}
cout << ans << endl;
}
int main()
{
do {
solve();
} while (DEBUG);
}
tomarint2