# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758945 | Dexva | Voting Cities (NOI22_votingcity) | C++14 | 5 ms | 1236 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define lln long long
const long long INF = numeric_limits<long long>::max();
using pll = pair<long,long>;
void solve() {
lln N, E, K; cin >> N >> E >> K;
vector<lln> cities(N+1), vcities(K); //cities are 0-indexed,, 1 city will be the mega target (coalsced voting cities)
vector<pll> roads(E);
map<lln, vector<pll> > adj;
for (lln i=0;i<K;i++) cin >> vcities[i]; //list of voting cities
for (lln i=0;i<E;i++) {
lln u, v, c; cin >> u >> v >> c; //we reverse the graph so instead of u->v, v-> u (see notes for subtask 2)
adj[v].push_back({u,c});
}
//connecting mega target (which is city `N`)
for (auto& vc : vcities) adj[N].push_back({vc,0});
//dijkstra proper
vector<lln> d(N+1,INF);
vector<bool> done(N+1,false);
lln source = N;
priority_queue<pll, vector<pll>, greater<pll> > pq;
pq.push({0, source}); // first parameter of pll is the distance/total weight, second parameter is index
d[source] = 0;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |