# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
265362 | T0p_ | Sightseeing (NOI14_sightseeing) | C++14 | 3566 ms | 202684 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 pb push_back
struct DATA
{
int node, val;
bool operator < (const DATA & o) const
{
return val < o.val;
}
};
int ans[500500];
priority_queue<DATA> heap;
vector<DATA> g[500500];
int main()
{
int n, m, q;
scanf(" %d %d %d",&n,&m,&q);
while(m--)
{
int u, v, w;
scanf(" %d %d %d",&u,&v,&w);
g[u].pb({v, w}), g[v].pb({u, w});
}
heap.push({1, 1000000000});
while(!heap.empty())
{
int nown = heap.top().node;
int nowv = heap.top().val;
heap.pop();
for(auto x : g[nown])
{
int vv = min(nowv, x.val);
if(vv > ans[x.node])
{
ans[x.node] = vv;
heap.push({x.node, ans[x.node]});
}
}
}
while(q--)
{
int d;
scanf(" %d",&d);
printf("%d\n",ans[d]);
}
return 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... |