Submission #758261

#TimeUsernameProblemLanguageResultExecution timeMemory
758261ivazivaCrocodile's Underground City (IOI11_crocodile)C++14
0 / 100
0 ms340 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; #define MAXN 1010 int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]) { long long n; long long m; long long k; vector<pair<long long,long long>> adj[MAXN]; long long niz[MAXN]; long long dist1[MAXN]; long long dist2[MAXN]; long long pos[MAXN]; n=N; m=M; k=K; for (long long i=0;i<m;i++) { long long x=R[i][0]; long long y=R[i][1]; long long z=L[i]; adj[x].push_back({y,z}); adj[y].push_back({x,z}); } for (long long i=0;i<MAXN;i++) { dist1[i]=LLONG_MAX; dist2[i]=LLONG_MAX; } priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> pq; for (long long i=0;i<k;i++) { niz[i+1]=P[i-1]; pq.push({0,niz[i+1]}); dist1[niz[i+1]]=0; dist2[niz[i+1]]=0; pos[niz[i+1]]=1; } while (pq.empty()==false) { long long node0=pq.top().second; long long dist0=pq.top().first; pq.pop(); if (dist0>dist2[node0]) continue; if (pos[node0]>1) continue; long long s=adj[node0].size(); for (long long i=0;i<s;i++) { long long node=adj[node0][i].first; long long dist=adj[node0][i].second; if (dist0+dist<dist1[node]) { dist2[node]=dist1[node]; dist1[node]=dist0+dist; pq.push({dist1[node],node}); } else if (dist0+dist<dist2[node]) { dist2[node]=dist0+dist; pq.push({dist2[node],node}); } } pos[node0]++; } return (int)dist2[0]; }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:10:15: warning: variable 'n' set but not used [-Wunused-but-set-variable]
   10 |     long long n;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...