結果
| 問題 | No.807 umg tours |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-11 20:35:16 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 2,770 bytes |
| 記録 | |
| コンパイル時間 | 2,460 ms |
| コンパイル使用メモリ | 246,124 KB |
| 実行使用メモリ | 18,296 KB |
| 最終ジャッジ日時 | 2026-11-11 20:35:34 |
| 合計ジャッジ時間 | 16,869 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 TLE * 1 -- * 1 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <cmath>
#include <climits>
#define LL long long
#define ALL(variable) (variable).begin(), (variable).end()
#define GT(variableName, defaultValue, limit) for(int variableName = defaultValue; variableName < (int)limit; variableName++)
#define GTE(variableName, defaultValue, limit) for(int variableName = defaultValue; variableName <= (int)limit; variableName++)
#define LT(variableName, defaultValue, limit) for(int variableName = defaultValue; variableName > (int)limit; variableName--)
#define LTE(variableName, defaultValue, limit) for(int variableName = defaultValue; variableName >= (int)limit; variableName--)
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
using namespace std ;
int main(){
int N, M;
cin >> N >> M;
vector<vector<pair<int, int>>> route(N, vector<pair<int, int>>(0));
priority_queue<tuple<LL, int, bool>, vector<tuple<LL, int, bool>>, greater<tuple<LL, int, bool>>> d;
vector<LL> cost(N, LLONG_MAX), cost0(N, LLONG_MAX);
tuple<LL, int, bool> here;
cost[0] = cost0[0] = 0;
d.push(make_tuple(0, 0, false));
GT(i, 0, M){
int a, b, c;
cin >> a >> b >> c;
a--; b--;
route[a].push_back(make_pair(b, c));
route[b].push_back(make_pair(a, c));
}
while(d.size() >= 1){
here = d.top();
d.pop();
int currentPotision = get<1>(here);
GT(i, 0, route[currentPotision].size()){
if(!get<2>(here)){
if(cost[route[currentPotision][i].first] > get<0>(here) + route[currentPotision][i].second){
cost[route[currentPotision][i].first] = get<0>(here) + route[currentPotision][i].second;
d.push(make_tuple(cost[route[currentPotision][i].first], route[currentPotision][i].first, get<2>(here)));
}
if(cost0[route[currentPotision][i].first] > get<0>(here)){
cost0[route[currentPotision][i].first] = get<0>(here);
d.push(make_tuple(cost0[route[currentPotision][i].first], route[currentPotision][i].first, true));
}
}
else{
if(cost0[route[currentPotision][i].first] > get<0>(here) + route[currentPotision][i].second){
cost0[route[currentPotision][i].first] = get<0>(here) + route[currentPotision][i].second;
d.push(make_tuple(cost0[route[currentPotision][i].first], route[currentPotision][i].first, true));
}
}
}
}
GT(i, 0, N){
cout << cost[i] + cost0[i] << endl;
}
return 0;
}