# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36229 | Flumen | Price List (POI13_cen) | C++11 | 143 ms | 10660 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;
vector<pair<int,int> >node[100100];
int ans[100100],mark[100100];
queue<pair<int,int> >Q;
priority_queue<pair<int,int> >X;
void d(int k,int b){
int i;
Q.push(make_pair(k,0));
while(!Q.empty()){
mark[Q.front().first]=1;
for(i=0;i<node[Q.front().first].size();i++){
if(mark[node[Q.front().first][i].first])continue;
mark[node[Q.front().first][i].first]=1;
Q.push(make_pair(node[Q.front().first][i].first,Q.front().first));
if(Q.front().second!=0){
node[node[Q.front().first][i].first].push_back(make_pair(Q.front().second,b));
node[Q.front().second].push_back(make_pair(node[Q.front().first][i].first,b));
}
}
Q.pop();
}
}
void dij(int k){
int i,x,y;
X.push(make_pair(0,k));
while(!X.empty()){
x=X.top().second;
y=X.top().first;
X.pop();
if(mark[x])continue;
mark[x]=1;
ans[x]=y*-1;
for(i=0;i<node[x].size();i++){
if(mark[node[x][i].first])continue;
X.push(make_pair(y-node[x][i].second,node[x][i].first));
}
}
}
int main(){
int n,m,k,a,b,i,x,y;
scanf("%d%d%d%d%d",&n,&m,&k,&a,&b);
for(i=0;i<m;i++)
{
scanf("%d%d",&x,&y);
node[x].push_back(make_pair(y,a));
node[y].push_back(make_pair(x,a));
}
d(k,b);
for(i=1;i<=n;i++)mark[i]=0;
dij(k);
for(i=1;i<=n;i++)printf("%d\n",ans[i]);
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... |
# | 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... |