Submission #44542

#TimeUsernameProblemLanguageResultExecution timeMemory
44542zetapiSightseeing (NOI14_sightseeing)C++14
15 / 25
3554 ms206152 KiB
/* Contest : Task : */ #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define F first #define S second #define itr ::iterator typedef pair<int,int> pii; const int MAX=6e5+99; set<pii> vec[MAX]; int V,E,Q,X,Y,Z,res[MAX]; void dijkstra() { int tem; pii cur; set<pii> pq; set<pii> ::iterator it; pq.insert(mp(MAX,1)); res[1]=MAX; while(! pq.empty()) { cur=*pq.rbegin(); it=pq.end(); it--; pq.erase(it); for(auto A:vec[cur.second]) { tem=min(cur.first,A.second); if(tem>res[A.first]) { if(res[A.first]) pq.erase(pq.find(mp(res[A.first],A.first))); res[A.first]=tem; pq.insert(mp(res[A.first],A.first)); } } for(auto A:vec[cur.second]) vec[A.first].erase(vec[A.first].find(mp(cur.second,A.second))); vec[cur.second].clear(); } return ; } signed main() { //ios_base::sync_with_stdio(false); /*cin.tie(0); cout.tie(0);*/ //cin>>V>>E>>Q; scanf("%d %d %d",&V,&E,&Q); while(E--) { scanf("%d %d %d",&X,&Y,&Z); vec[X].insert(mp(Y,Z)); vec[Y].insert(mp(X,Z)); } dijkstra(); while(Q--) { scanf("%d",&X); printf("%d\n",res[X]); } return 0; }

Compilation message (stderr)

sightseeing.cpp: In function 'int main()':
sightseeing.cpp:63:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&V,&E,&Q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
sightseeing.cpp:66:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&X,&Y,&Z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
sightseeing.cpp:73:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&X);
   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...