Submission #36229

#TimeUsernameProblemLanguageResultExecution timeMemory
36229FlumenPrice List (POI13_cen)C++11
0 / 100
143 ms10660 KiB
#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)

cen.cpp: In function 'void d(int, int)':
cen.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0;i<node[Q.front().first].size();i++){
                  ^
cen.cpp: In function 'void dij(int)':
cen.cpp:34:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0;i<node[x].size();i++){
                  ^
cen.cpp: In function 'int main()':
cen.cpp:42:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d",&n,&m,&k,&a,&b);
                                       ^
cen.cpp:45:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x,&y);
                            ^
#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...