Submission #671252

#TimeUsernameProblemLanguageResultExecution timeMemory
671252groshiCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
507 ms67236 KiB
#include<iostream> #include<vector> #include<queue> using namespace std; struct wi{ vector<int> Q; int odw=0; int ktory=0; }*w; int travel_plan(int n,int m,int R[][2],int L[],int k,int P[]) { w=new wi[n+3]; for(int i=0;i<m;i++) { int x=R[i][0]; int y=R[i][1]; int z=L[i]; cin>>x>>y>>z; w[x].Q.push_back(y); w[x].Q.push_back(z); w[y].Q.push_back(x); w[y].Q.push_back(z); } priority_queue<pair<int,int> > kolejka; for(int i=0;i<k;i++) { int x=P[i]; w[x].odw=1; for(int j=0;j<w[x].Q.size();j+=2) { int pom=w[x].Q[j]; kolejka.push({-w[x].Q[j+1],pom}); } } while(!kolejka.empty()) { auto para=kolejka.top(); kolejka.pop(); if(w[para.second].odw) continue; w[para.second].ktory++; if(w[para.second].ktory==2) { if(para.second==0) return -para.first; w[para.second].odw=1; for(int i=0;i<w[para.second].Q.size();i+=2) { int pom=w[para.second].Q[i]; if(w[pom].odw) continue; kolejka.push({para.first-w[para.second].Q[i+1],pom}); } } } return -1; }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int j=0;j<w[x].Q.size();j+=2)
      |                     ~^~~~~~~~~~~~~~
crocodile.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(int i=0;i<w[para.second].Q.size();i+=2)
      |                         ~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...