제출 #971519

#제출 시각아이디문제언어결과실행 시간메모리
971519Spade1Evacuation plan (IZhO18_plan)C++14
23 / 100
269 ms30508 KiB
#pragma once #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<pld> vpld; typedef vector<vi> vvi; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; template<typename T> using pq = priority_queue<T>; template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>; #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define st first #define nd second #define lb lower_bound #define ub upper_bound #define all(x) (x).begin(), (x).end() #define ins insert template<typename T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MOD = 1e9 + 7; const int INF = 0x3fffffff; const ll LINF = 0x1fffffffffffffff; const char nl = '\n'; const int MX = 1e5 + 3; vpii adj[MX]; int dis[MX], rnk[MX], lvl[MX]; pii par[MX]; int f(int i) { if (par[i].st == i) return i; lvl[i] = lvl[par[i].st]+1; return f(par[i].st); } void join(int a, int b, int w) { int fa = f(a), fb = f(b); if (rnk[fa] > rnk[fb]) swap(fa, fb); par[fa] = {fb, w}; rnk[fb] += (rnk[fb] == rnk[fa]); } int query(int u, int v) { int ret = INF; if (lvl[u] < lvl[v]) swap(u, v); while (lvl[v] < lvl[u]) ckmin(ret, par[u].nd), u = par[u].st; while (u != v) { ckmin(ret, par[u].nd), u = par[u].st; ckmin(ret, par[v].nd), v = par[v].st; } return min(ret, par[u].nd); } void solve() { int n, m; cin >> n >> m; for (int i = 1; i <= m; ++i) { int u, v, w; cin >> u >> v >> w; adj[u].pb({v, w}); adj[v].pb({u, w}); } pqg<pii> pq; fill(dis, dis+MX, INF); int k; cin >> k; for (int i = 1; i <= k; ++i) { int g; cin >> g; pq.push({dis[g] = 0, g}); } //dijkstra while (!pq.empty()) { auto [cur, a] = pq.top(); pq.pop(); if (cur > dis[a]) continue; for (auto [b, w] : adj[a]) { if (ckmin(dis[b], dis[a]+w)) pq.push({dis[b], b}); } } vpii v; for (int i = 1; i <= n; ++i) v.pb({-dis[i], i}), par[i] = {i, dis[i]}; //DSU by rank sort(all(v)); for (auto [w, a] : v) { for (auto [b, w] : adj[a]) { if (dis[b] >= dis[a] && f(a) != f(b)) join(a, b, dis[a]); } } //finding the levels for (int i = 1; i <= n; ++i) f(i); int q; cin >> q; while (q--) { int u, v; cin >> u >> v; cout << min(dis[u], dis[v]) << nl; } } int main(int argc, char* argv[]) { ios_base::sync_with_stdio(0); cin.tie(NULL); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

plan.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
plan.cpp: In function 'void solve()':
plan.cpp:88:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   88 |     auto [cur, a] = pq.top(); pq.pop();
      |          ^
plan.cpp:90:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   90 |     for (auto [b, w] : adj[a]) {
      |               ^
plan.cpp:99:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   99 |   for (auto [w, a] : v) {
      |             ^
plan.cpp:100:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  100 |     for (auto [b, w] : adj[a]) {
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...