結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | nuxxpp |
提出日時 | 2021-04-11 02:26:02 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 2,341 bytes |
コンパイル時間 | 3,289 ms |
コンパイル使用メモリ | 168,132 KB |
実行使用メモリ | 10,112 KB |
最終ジャッジ日時 | 2024-06-26 22:53:08 |
合計ジャッジ時間 | 7,151 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 65 ms
9,728 KB |
testcase_03 | AC | 48 ms
9,344 KB |
testcase_04 | AC | 36 ms
8,012 KB |
testcase_05 | AC | 15 ms
6,940 KB |
testcase_06 | AC | 61 ms
9,728 KB |
testcase_07 | AC | 62 ms
9,936 KB |
testcase_08 | AC | 74 ms
10,068 KB |
testcase_09 | AC | 59 ms
9,944 KB |
testcase_10 | AC | 33 ms
7,808 KB |
testcase_11 | AC | 32 ms
8,704 KB |
testcase_12 | AC | 33 ms
8,320 KB |
testcase_13 | AC | 22 ms
7,296 KB |
testcase_14 | AC | 16 ms
6,940 KB |
testcase_15 | AC | 28 ms
7,936 KB |
testcase_16 | AC | 32 ms
7,680 KB |
testcase_17 | AC | 6 ms
6,940 KB |
testcase_18 | AC | 7 ms
6,944 KB |
testcase_19 | AC | 34 ms
8,200 KB |
testcase_20 | AC | 44 ms
8,832 KB |
testcase_21 | AC | 54 ms
9,088 KB |
testcase_22 | AC | 58 ms
9,932 KB |
testcase_23 | AC | 47 ms
8,900 KB |
testcase_24 | AC | 44 ms
8,908 KB |
testcase_25 | AC | 60 ms
9,736 KB |
testcase_26 | AC | 63 ms
9,728 KB |
testcase_27 | AC | 23 ms
7,296 KB |
testcase_28 | AC | 62 ms
9,788 KB |
testcase_29 | AC | 47 ms
8,832 KB |
testcase_30 | AC | 57 ms
9,600 KB |
testcase_31 | AC | 66 ms
10,016 KB |
testcase_32 | AC | 56 ms
9,984 KB |
testcase_33 | AC | 47 ms
9,088 KB |
testcase_34 | AC | 22 ms
7,680 KB |
testcase_35 | AC | 29 ms
7,808 KB |
testcase_36 | AC | 43 ms
8,468 KB |
testcase_37 | AC | 43 ms
8,772 KB |
testcase_38 | AC | 10 ms
6,940 KB |
testcase_39 | AC | 32 ms
7,680 KB |
testcase_40 | AC | 34 ms
7,680 KB |
testcase_41 | AC | 30 ms
7,452 KB |
testcase_42 | AC | 30 ms
7,448 KB |
testcase_43 | AC | 43 ms
10,112 KB |
testcase_44 | AC | 43 ms
10,112 KB |
testcase_45 | AC | 43 ms
10,112 KB |
testcase_46 | AC | 44 ms
8,500 KB |
testcase_47 | AC | 53 ms
9,160 KB |
testcase_48 | AC | 46 ms
8,864 KB |
コンパイルメッセージ
main.cpp: In function 'int di_m(int, int)': main.cpp:60:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 60 | auto [v, w] = g[e.now][i]; | ^ main.cpp: In function 'int diks(int, int, int)': main.cpp:79:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 79 | auto [v, w] = g[e.now][i]; | ^ main.cpp: In function 'int di_m(int, int)': main.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type] 67 | } | ^ main.cpp: In function 'int diks(int, int, int)': main.cpp:86:1: warning: control reaches end of non-void function [-Wreturn-type] 86 | } | ^
ソースコード
#include <iostream> #include <iomanip> #include <cstdio> #include <queue> #include <cstring> #include <vector> #include <map> #include <algorithm> #include <cctype> #include <cmath> #include <bitset> #include <set> #include <deque> #include <stack> #include <atcoder/all> using namespace std; #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < (t); ++i) #define dsrep(i,t,s) for(int i = (t)-1; i >= (s); --i) #define rng(a) a.begin(),a.end() #define rrng(a) a.rbegin(),a.rend() #define isin(x,l,r) ((l) <= (x) && (x) < (r)) int dx4[4]={1,0,-1,0}; int dy4[4]={0,-1,0,1}; using ll = long long; using uint = unsigned; using ull = unsigned long long; using P = pair<int,int>; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; const ll mod = 998244353; //////////////////////////////////////////// int n, m; vector<P> g[100005]; struct edge { int now, front, we; bool operator< (edge edge2) const { return we < edge2.we; } bool operator> (edge edge2) const { return we > edge2.we; } }; int di_m(int s, int goal) { priority_queue<edge> que; vector<int> d(n, -1); que.push(edge{s, -1, INF}); while (!que.empty()) { edge e = que.top(); que.pop(); if(d[e.now] > e.we) continue; if(e.now == goal) return e.we; for(int i = 0; i < g[e.now].size(); i++) { auto [v, w] = g[e.now][i]; if(d[v] < min(e.we, w)) { d[v] = min(e.we, w); que.push(edge{v, e.now, d[v]}); } } } } int diks(int s, int goal, int ma) { priority_queue<edge, vector<edge>, greater<edge>> que; vector<int> d(n, INF); que.push(edge{s, -1, 0}); d[s] = 0; while (!que.empty()) { edge e = que.top(); que.pop(); if(e.now == goal) return e.we; for(int i = 0; i < g[e.now].size(); i++) { auto [v, w] = g[e.now][i]; if(w >= ma && d[v] > e.we + 1) { d[v] = e.we + 1; que.push(edge{v, e.now, d[v]}); } } } } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; int a, b, c; rep(i, m) { cin >> a >> b >> c; a--; b--; g[a].push_back(P(b, c)); g[b].push_back(P(a, c)); } int ma = di_m(0, n - 1); cout << ma << " " << diks(0, n - 1, ma) << endl; }