Submission #980115

#TimeUsernameProblemLanguageResultExecution timeMemory
980115MaaxleClosing Time (IOI23_closing)C++17
0 / 100
90 ms21844 KiB
#include "closing.h" #include <bits/stdc++.h> #define range(it, a, b) for (ll it = a; it < b; it++) #define all(x) begin(x), end(x) #define ll long long #define ull unsigned long long #define INF64 ((ll) 1 << 60) #define INF32 ((ll) 1 << 30) #define uset unordered_set #define umap unordered_map #define pqueue priority_queue using namespace std; struct Road { ll i, w; }; bool operator < (const Road& a, const Road& b) { return a.w > b.w; } ll ans, k; vector<vector<Road>> adj; vector<ll> close; void dijkstra(ll X, ll Y) { pqueue<Road> pq; pq.push({X, 0}); pq.push({Y, 0}); Road t; while (!pq.empty()) { t = pq.top(); pq.pop(); if (close[t.i] != -1) continue; if (k - t.w < 0) return; close[t.i] = t.w; ans++; k -= t.w; for (Road& k : adj[t.i]) { Road nt = {k.i, t.w + k.w}; if (close[k.i] == -1) pq.push(nt); } } } int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W) { close.resize(N, -1); adj.resize(N); k = K; range(i, 0, N-1) { adj[U[i]].push_back({V[i], W[i]}); adj[V[i]].push_back({U[i], W[i]}); } dijkstra(X, Y); return ans; }
#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...
#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...