結果
| 問題 | No.468 役に立つ競技プログラミング実践編 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-18 18:03:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,233 bytes |
| 記録 | |
| コンパイル時間 | 770 ms |
| コンパイル使用メモリ | 78,252 KB |
| 実行使用メモリ | 34,472 KB |
| 最終ジャッジ日時 | 2024-12-14 08:27:53 |
| 合計ジャッジ時間 | 32,500 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 7 WA * 14 TLE * 10 |
| other | AC * 6 |
コンパイルメッセージ
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:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d%d%lld", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
using namespace std;
using i64 = long long;
struct edge {
int to; i64 cost;
};
vector<vector<edge>> G0, rG;
vector<int> cost0, rcost;
int main(void) {
int n, m; scanf("%d%d", &n, &m);
G0.assign(n, vector<edge>());
rG.assign(n, vector<edge>());
int a, b; i64 c;
for(int i=0; i<m; ++i) {
scanf("%d%d%lld", &a, &b, &c);
G0[a].push_back(edge({b, c}));
rG[b].push_back(edge({a, c}));
}
cost0.assign(n, 0);
queue<int> que;
que.push(0);
while(!que.empty()) {
int v = que.front(); que.pop();
for(edge e : G0[v]) {
if(cost0[e.to] < cost0[v] + e.cost) {
cost0[e.to] = cost0[v] + e.cost;
que.push(e.to);
}
}
}
rcost.assign(n, 0);
que.push(n-1);
while(!que.empty()) {
int v = que.front(); que.pop();
for(edge e : rG[v]) {
if(rcost[e.to] < rcost[v] + e.cost) {
rcost[e.to] = rcost[v] + e.cost;
que.push(e.to);
}
}
}
int days = cost0[n-1];
for(int i=0; i<n; ++i) { rcost[i] = days - rcost[i]; }
int cnt = 0;
for(int i=0; i<n; ++i) {
if(cost0[i] != rcost[i]) { ++cnt; }
}
printf("%d %d/%d\n", days, cnt, n);
return 0;
}