結果
問題 | No.468 役に立つ競技プログラミング実践編 |
ユーザー | Konton7 |
提出日時 | 2020-02-07 00:06:56 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 384 ms / 2,000 ms |
コード長 | 2,121 bytes |
コンパイル時間 | 2,468 ms |
コンパイル使用メモリ | 214,420 KB |
実行使用メモリ | 26,676 KB |
最終ジャッジ日時 | 2024-09-25 07:03:28 |
合計ジャッジ時間 | 9,393 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 3 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 3 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 4 ms
5,376 KB |
testcase_15 | AC | 4 ms
5,376 KB |
testcase_16 | AC | 4 ms
5,376 KB |
testcase_17 | AC | 4 ms
5,376 KB |
testcase_18 | AC | 4 ms
5,376 KB |
testcase_19 | AC | 5 ms
5,376 KB |
testcase_20 | AC | 4 ms
5,376 KB |
testcase_21 | AC | 5 ms
5,376 KB |
testcase_22 | AC | 4 ms
5,376 KB |
testcase_23 | AC | 4 ms
5,376 KB |
testcase_24 | AC | 377 ms
26,492 KB |
testcase_25 | AC | 375 ms
26,548 KB |
testcase_26 | AC | 380 ms
26,672 KB |
testcase_27 | AC | 384 ms
26,516 KB |
testcase_28 | AC | 381 ms
26,496 KB |
testcase_29 | AC | 378 ms
26,676 KB |
testcase_30 | AC | 376 ms
26,640 KB |
testcase_31 | AC | 380 ms
26,620 KB |
testcase_32 | AC | 378 ms
26,488 KB |
testcase_33 | AC | 374 ms
26,616 KB |
testcase_34 | AC | 118 ms
22,788 KB |
testcase_35 | AC | 3 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = std::pair<int, int>; using PLL = std::pair<ll, ll>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) const int mod = 1e9 + 7; const ll maxint = 1e15; vector<ll> shortest, shortest2, indegree, outdegree; vector<vector<pair<int, int>>> connective, connective2; void djkstra(int x, vector<vector<pair<int, int>>> connective, vector<ll> &shortest, vector<ll> °ree) { vector<int> search = {x}; vector<int> new_search; shortest[x] = 0; int v, d; while (!search.empty()) { for (auto itr = search.begin(); itr != search.end(); itr++) { for (auto itr2 = connective[*itr].begin(); itr2 != connective[*itr].end(); itr2++) { v = itr2->first, d = itr2->second; degree[v] -= 1; shortest[v] = max(shortest[v], shortest[*itr] + d); if (degree[v] == 0) new_search.push_back(v); } } search.clear(); search = new_search; new_search.clear(); } } int main() { #ifdef DEBUG cout << "DEBUG MODE" << endl; ifstream in("input.txt"); //for debug cin.rdbuf(in.rdbuf()); //for debug #endif int n, m, s, t, c, r; cin >> n >> m; connective.resize(n), connective2.resize(n); rep(i, n) { shortest.push_back(0); shortest2.push_back(0); indegree.push_back(0); outdegree.push_back(0); } rep(i, m) { cin >> s >> t >> c; connective[s].push_back(make_pair(t, c)); connective2[t].push_back(make_pair(s, c)); indegree[s] += 1; outdegree[t] += 1; } djkstra(0, connective, shortest, outdegree); djkstra(n - 1, connective2, shortest2, indegree); r = 0; rep(i, n) { shortest2[i] = shortest[n - 1] - shortest2[i]; if (shortest[i] == shortest2[i]) r++; } cout << shortest[n - 1] << " " << n - r << "/" << n << endl; return 0; }