結果
問題 |
No.468 役に立つ競技プログラミング実践編
|
ユーザー |
|
提出日時 | 2016-12-18 18:40:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,303 bytes |
コンパイル時間 | 688 ms |
コンパイル使用メモリ | 68,624 KB |
実行使用メモリ | 16,652 KB |
最終ジャッジ日時 | 2024-12-14 08:31:20 |
合計ジャッジ時間 | 3,224 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 31 |
other | AC * 5 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:16:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | int n, m; scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d%d%d", &a, &b, &c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream> #include <algorithm> #include <queue> #include <tuple> using namespace std; struct edge { int from, to, cost; }; vector<edge> G0, rG; vector<int> cost0, rcost; int main(void) { constexpr int inf = 1; int n, m; scanf("%d%d", &n, &m); int a, b, c; for(int i=0; i<m; ++i) { scanf("%d%d%d", &a, &b, &c); G0.push_back(edge({a, b, -c})); rG.push_back(edge({b, a, -c})); } cost0.assign(n, inf); cost0[0] = 0; while(true) { bool update = false; for(int i=0; i<m; ++i) { edge e = G0[i]; if(cost0[e.from] != inf && cost0[e.to] > cost0[e.from] + e.cost) { cost0[e.to] = cost0[e.from] + e.cost; update = true; } } if(!update) { break; } } int days = -cost0[n-1]; // rcost.assign(n, inf); // rcost[n-1] = 0; // while(true) { // bool update = false; // for(int i=0; i<m; ++i) { // edge e = rG[i]; // if(rcost[e.from] != inf && rcost[e.to] > rcost[e.from] + e.cost) { // rcost[e.to] = rcost[e.from] + e.cost; // update = true; // } // } // if(!update) { break; } // } // // int cnt = 0; // for(int i=0; i<n; ++i) { // if(-cost0[i] != days + rcost[i]) { ++cnt; } // } // printf("%d %d/%d\n", days, cnt, n); printf("%d 0/%d\n", days, n); return 0; }