Submission #378590

#TimeUsernameProblemLanguageResultExecution timeMemory
378590rk42745417Evacuation plan (IZhO18_plan)C++17
23 / 100
415 ms18412 KiB
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using ull = uint64_t; using uint = uint32_t; using ld = long double; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const ll LINF = 2e18; const double EPS = 1e-9; #define EMT ios::sync_with_stdio(0); cin.tie(0); const int N = 1e5 + 25; int dis[N]; vector<int> npp; vector<pair<int, int>> edge[N]; void solve() { memset(dis, 0x3f, sizeof dis); priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; for(int a : npp) dis[a] = 0, pq.push({dis[a], a}); while(!pq.empty()) { auto [c, u] = pq.top(); pq.pop(); if(c > dis[u]) continue; for(const auto &[v, d] : edge[u]) { if(dis[v] > c + d) { dis[v] = c + d; pq.push({dis[v], v}); } } } } void solve2(int n) { // direct road int q; cin >> q; while(q--) { int s, t; cin >> s >> t; cout << min(dis[s], dis[t]) << '\n'; } } void solve1(int n) { // n <= 15 solve2(n); return; int q; cin >> q; while(q--) { int s, t; int res = INF; for(int i = 0; i < (1 << n); i++) { } } } signed main() { EMT int n, m; cin >> n >> m; for(int i = 0; i < m; i++) { int u, v, w; cin >> u >> v >> w; edge[u].push_back({v, w}); edge[v].push_back({u, w}); } int k; cin >> k; npp.resize(k); for(int &a : npp) cin >> a; solve(); if(n <= 15) { solve1(n); } else solve2(n); } /* 9 12 1 9 4 1 2 5 2 3 7 2 4 3 4 3 6 3 6 4 8 7 10 6 7 5 5 8 1 9 5 7 5 4 12 6 8 2 2 4 7 5 1 6 5 3 4 8 5 8 1 5 */

Compilation message (stderr)

plan.cpp: In function 'void solve1(int)':
plan.cpp:53:7: warning: unused variable 's' [-Wunused-variable]
   53 |   int s, t;
      |       ^
plan.cpp:53:10: warning: unused variable 't' [-Wunused-variable]
   53 |   int s, t;
      |          ^
plan.cpp:54:7: warning: unused variable 'res' [-Wunused-variable]
   54 |   int res = INF;
      |       ^~~
#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...