結果
| 問題 |
No.845 最長の切符
|
| コンテスト | |
| ユーザー |
lotus
|
| 提出日時 | 2019-06-28 22:19:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 737 bytes |
| コンパイル時間 | 1,745 ms |
| コンパイル使用メモリ | 173,924 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 04:51:53 |
| 合計ジャッジ時間 | 2,730 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long i64;
typedef pair<i64,i64> P;
int n, m;
vector<P> v[20];
int main(){
cin >> n >> m;
for(int i = 0; i < m; i++){
int a,b,c;
cin >> a >> b >> c;
v[a].push_back(P(b,c));
v[b].push_back(P(a,c));
}
i64 ans = 0;
for(int i = 1; i <= n; i++){
bool b[20] = {0};
queue<P> q;
q.push(P(i, 0));
while(!q.empty()){
P p = q.front();
q.pop();
b[p.first] = 1;
ans = max(ans, p.second);
for(int j = 0; j < v[p.first].size(); j++){
if(b[v[p.first][j].first]) continue;
q.push(P(v[p.first][j].first, p.second + v[p.first][j].second));
}
}
}
cout << ans << endl;
return 0;
}
lotus