# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433093 | Monchito | Paint By Numbers (IOI16_paint) | C++14 | 0 ms | 0 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.
ll dijkstra(int x) {
priority_queue<pair<ll, int>> q;
vector<ll> dist(N, INF);
dist[x] = 0;
q.push(make_pair(-0, x));
while(!q.empty()) {
pair<ll, int> p = q.top(); q.pop();
int u = p.second;
if(-p.first != dist[u]) continue;
for(int i=0; i<(int)G[u].size(); i++) {
int v = G[u][i];
ll w = W[u][i];
if(-p.first + w < dist[v]) {
dist[v] = -p.first + w;
q.push( {-dist[v], v } );
}
}
}
ll ret=0;
for(int i=0; i<N; i++) ret = max(ret, dist[i]);
return ret;
}