結果
| 問題 |
No.845 最長の切符
|
| コンテスト | |
| ユーザー |
tomarint2
|
| 提出日時 | 2019-06-28 22:39:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,198 bytes |
| コンパイル時間 | 744 ms |
| コンパイル使用メモリ | 83,900 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-02 05:00:08 |
| 合計ジャッジ時間 | 7,358 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 14 |
ソースコード
#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
#define INF 1e18
ll N,M;
vector<vector<pll>> to(16);
ll dfs(ll sc, ll loc, ll arr)
{
if ((arr & (1LL << loc)) != 0) {
return -INF;
}
arr |= (1LL << loc);
ll ret = sc;
for (auto t : to[loc]) {
ret = max(ret, dfs(sc + t.second, t.first, arr));
}
return ret;
}
void solve()
{
ll i;
cin >> N >> M;
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) {
ans = max(ans,dfs(0,i,0));
}
cout << ans << endl;
}
int main()
{
do {
solve();
} while (DEBUG);
}
tomarint2