結果
問題 | No.1480 Many Complete Graphs |
ユーザー | Mister |
提出日時 | 2021-04-16 21:37:51 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 2,583 bytes |
コンパイル時間 | 758 ms |
コンパイル使用メモリ | 86,876 KB |
実行使用メモリ | 17,040 KB |
最終ジャッジ日時 | 2024-07-03 04:13:41 |
合計ジャッジ時間 | 4,771 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 12 ms
8,320 KB |
testcase_14 | AC | 9 ms
6,944 KB |
testcase_15 | AC | 23 ms
9,964 KB |
testcase_16 | AC | 13 ms
8,064 KB |
testcase_17 | AC | 13 ms
7,552 KB |
testcase_18 | AC | 5 ms
6,944 KB |
testcase_19 | AC | 15 ms
7,552 KB |
testcase_20 | AC | 21 ms
8,812 KB |
testcase_21 | AC | 14 ms
8,064 KB |
testcase_22 | AC | 9 ms
6,940 KB |
testcase_23 | AC | 27 ms
12,928 KB |
testcase_24 | AC | 33 ms
11,796 KB |
testcase_25 | AC | 46 ms
14,120 KB |
testcase_26 | AC | 49 ms
14,856 KB |
testcase_27 | AC | 34 ms
11,900 KB |
testcase_28 | AC | 46 ms
15,124 KB |
testcase_29 | AC | 48 ms
15,116 KB |
testcase_30 | AC | 45 ms
15,240 KB |
testcase_31 | AC | 44 ms
14,088 KB |
testcase_32 | AC | 46 ms
15,112 KB |
testcase_33 | AC | 51 ms
15,244 KB |
testcase_34 | AC | 45 ms
15,236 KB |
testcase_35 | AC | 42 ms
15,228 KB |
testcase_36 | AC | 45 ms
15,096 KB |
testcase_37 | AC | 44 ms
15,228 KB |
testcase_38 | AC | 44 ms
15,096 KB |
testcase_39 | AC | 41 ms
14,068 KB |
testcase_40 | AC | 42 ms
15,228 KB |
testcase_41 | AC | 38 ms
14,076 KB |
testcase_42 | AC | 45 ms
15,116 KB |
testcase_43 | AC | 42 ms
15,116 KB |
testcase_44 | AC | 39 ms
14,216 KB |
testcase_45 | AC | 42 ms
15,240 KB |
testcase_46 | AC | 44 ms
14,092 KB |
testcase_47 | AC | 67 ms
15,824 KB |
testcase_48 | AC | 67 ms
15,792 KB |
testcase_49 | AC | 72 ms
15,900 KB |
testcase_50 | AC | 45 ms
15,360 KB |
testcase_51 | AC | 74 ms
15,888 KB |
testcase_52 | AC | 59 ms
15,260 KB |
testcase_53 | AC | 55 ms
15,268 KB |
testcase_54 | AC | 59 ms
16,148 KB |
testcase_55 | AC | 55 ms
15,396 KB |
testcase_56 | AC | 54 ms
15,276 KB |
testcase_57 | AC | 39 ms
14,904 KB |
testcase_58 | AC | 51 ms
17,040 KB |
evil_aftercontest.txt | AC | 102 ms
31,628 KB |
ソースコード
#line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Graph/dijkstra.hpp" #line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Tools/heap_alias.hpp" #include <queue> template <class T> using MaxHeap = std::priority_queue<T>; template <class T> using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>; #line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Graph/graph.hpp" #include <vector> template <class Cost = int> struct Edge { int src, dst; Cost cost; Edge() = default; Edge(int src, int dst, Cost cost = 1) : src(src), dst(dst), cost(cost){}; bool operator<(const Edge<Cost>& e) const { return cost < e.cost; } bool operator>(const Edge<Cost>& e) const { return cost > e.cost; } }; template <class Cost = int> struct Graph : public std::vector<std::vector<Edge<Cost>>> { using std::vector<std::vector<Edge<Cost>>>::vector; void span(bool direct, int src, int dst, Cost cost = 1) { (*this)[src].emplace_back(src, dst, cost); if (!direct) (*this)[dst].emplace_back(dst, src, cost); } }; #line 5 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Graph/dijkstra.hpp" template <class Cost> std::vector<Cost> dijkstra(const Graph<Cost>& graph, int s) { std::vector<Cost> dist(graph.size(), -1); dist[s] = 0; MinHeap<std::pair<Cost, int>> que; que.emplace(0, s); while (!que.empty()) { auto [d, v] = que.top(); que.pop(); if (d > dist[v]) continue; for (const auto& e : graph[v]) { if (dist[e.dst] != -1 && dist[e.dst] <= dist[v] + e.cost) continue; dist[e.dst] = dist[v] + e.cost; que.emplace(dist[e.dst], e.dst); } } return dist; } #line 2 "main.cpp" #include <iostream> using namespace std; using lint = long long; void solve() { int n, m; cin >> n >> m; Graph<lint> graph(n + m * 2); for (int i = 0; i < m; ++i) { int k; lint c; cin >> k >> c; int r = n + i * 2; while (k--) { int v; cin >> v; graph.span(true, v - 1, r, (v + 1) / 2); graph.span(true, r, v - 1, (v + 1) / 2 + c); if (v % 2 != 0) { graph.span(true, v - 1, r + 1, (v + 1) / 2); graph.span(true, r + 1, v - 1, (v + 1) / 2 + c - 1); } } } cout << dijkstra(graph, 0)[n - 1] << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }