結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | shimarut |
提出日時 | 2021-04-10 22:13:21 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 211 ms / 2,000 ms |
コード長 | 3,692 bytes |
コンパイル時間 | 3,477 ms |
コンパイル使用メモリ | 190,240 KB |
実行使用メモリ | 9,780 KB |
最終ジャッジ日時 | 2024-06-26 10:38:50 |
合計ジャッジ時間 | 10,977 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 173 ms
9,536 KB |
testcase_03 | AC | 130 ms
8,628 KB |
testcase_04 | AC | 109 ms
6,656 KB |
testcase_05 | AC | 42 ms
5,376 KB |
testcase_06 | AC | 178 ms
8,800 KB |
testcase_07 | AC | 158 ms
9,768 KB |
testcase_08 | AC | 202 ms
9,776 KB |
testcase_09 | AC | 156 ms
9,780 KB |
testcase_10 | AC | 98 ms
5,504 KB |
testcase_11 | AC | 109 ms
6,400 KB |
testcase_12 | AC | 99 ms
6,016 KB |
testcase_13 | AC | 58 ms
5,376 KB |
testcase_14 | AC | 43 ms
5,376 KB |
testcase_15 | AC | 87 ms
5,632 KB |
testcase_16 | AC | 90 ms
5,504 KB |
testcase_17 | AC | 8 ms
5,376 KB |
testcase_18 | AC | 14 ms
5,376 KB |
testcase_19 | AC | 82 ms
6,016 KB |
testcase_20 | AC | 100 ms
8,044 KB |
testcase_21 | AC | 123 ms
7,040 KB |
testcase_22 | AC | 93 ms
8,616 KB |
testcase_23 | AC | 77 ms
8,104 KB |
testcase_24 | AC | 79 ms
7,840 KB |
testcase_25 | AC | 202 ms
8,320 KB |
testcase_26 | AC | 211 ms
8,436 KB |
testcase_27 | AC | 63 ms
5,376 KB |
testcase_28 | AC | 199 ms
9,552 KB |
testcase_29 | AC | 138 ms
7,168 KB |
testcase_30 | AC | 170 ms
7,936 KB |
testcase_31 | AC | 149 ms
9,588 KB |
testcase_32 | AC | 157 ms
8,980 KB |
testcase_33 | AC | 106 ms
7,928 KB |
testcase_34 | AC | 56 ms
5,888 KB |
testcase_35 | AC | 63 ms
5,632 KB |
testcase_36 | AC | 107 ms
6,400 KB |
testcase_37 | AC | 127 ms
7,812 KB |
testcase_38 | AC | 24 ms
5,376 KB |
testcase_39 | AC | 94 ms
5,376 KB |
testcase_40 | AC | 91 ms
5,376 KB |
testcase_41 | AC | 78 ms
5,376 KB |
testcase_42 | AC | 79 ms
5,376 KB |
testcase_43 | AC | 97 ms
7,276 KB |
testcase_44 | AC | 97 ms
7,228 KB |
testcase_45 | AC | 98 ms
7,276 KB |
testcase_46 | AC | 112 ms
7,424 KB |
testcase_47 | AC | 135 ms
8,384 KB |
testcase_48 | AC | 124 ms
7,980 KB |
ソースコード
#pragma region #define _USE_MATH_DEFINES #include <iostream> #include <string> #include <algorithm> #include <cmath> #include <cstdlib> #include <vector> #include <map> #include <queue> #include <stack> #include <set> #include <list> #include <iomanip> #include <cstdint> #include <bitset> #include <sstream> #include <regex> #include <fstream> #include <array> #include <atcoder/all> using namespace atcoder; //using mint = modint1000000007; //using mint = modint998244353; using mint = modint; using namespace std; typedef long long ll; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vmint = vector<mint>; using vvmint = vector<vmint>; using pint = pair<int, int>; using pll = pair<ll, ll>; using vpint = vector<pint>; using vvpint = vector<vpint>; //#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i)) #define rep(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i)) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #pragma region UnionFind struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; #pragma endregion #pragma region GCD ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a%b); } #pragma endregion #pragma region LCM ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } #pragma endregion #pragma region chmin template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } #pragma endregion #pragma region chmax template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } #pragma endregion #pragma region グリッド内チェック bool out(int x, int y, int h, int w) { if (x < 0 || h <= x || y < 0 || w <= y)return true; else return false; } #pragma endregion #pragma region Dijkstra vl dijkstra(vector<vector<pair<int, ll>>> v, int s) { ll INF = 1e18; int MAX = 1e6; vl res(MAX, INF); priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q; q.push({ 0,s }); while (!q.empty()) { int now; ll d; tie(d, now) = q.top(); q.pop(); if (!chmin(res[now], d))continue; for (auto p : v[now]) { int next; ll c; tie(next, c) = p; if (res[next] <= res[now] + c)continue; q.push({ res[now] + c,next }); } } return res; } #pragma endregion #pragma endregion int main() { int n, m; cin >> n >> m; vvpint v(n); rep(i, m) { int s, t, d; cin >> s >> t >> d; --s, --t; v[s].push_back({ t,d }); v[t].push_back({ s,d }); } int ok = 1, ng = 1e9 + 1; while (ng - ok > 1) { int mid = (ok + ng) / 2; vi dp(n, -1); dp[0] = 0; queue<int> q; q.push(0); while (!q.empty()) { int now = q.front(); q.pop(); for (auto p : v[now]) { int next, d; tie(next, d) = p; if (dp[next] == -1 && mid <= d) { dp[next] = dp[now] + 1; q.push(next); } } } if (dp[n - 1] != -1)ok = mid; else ng = mid; } vi dp(n, -1); dp[0] = 0; queue<int> q; q.push(0); while (!q.empty()) { int now = q.front(); q.pop(); for (auto p : v[now]) { int next, d; tie(next, d) = p; if (dp[next] == -1 && ok <= d) { dp[next] = dp[now] + 1; q.push(next); } } } cout << ok << " " << dp[n - 1] << endl; }