Submission #211316

#TimeUsernameProblemLanguageResultExecution timeMemory
211316sochoCrocodile's Underground City (IOI11_crocodile)C++14
0 / 100
13 ms5248 KiB
#include "bits/stdc++.h" using namespace std; // #define endl '\n' // #define int long long int n, m; const int MXN = 100005; vector<pair<int, int> > adj[MXN]; bool ter[MXN]; int dist[MXN]; int via[MXN]; int best(int node, int last) { if (ter[node]) return 0; vector<int> opts; for (int i=0; i<adj[node].size(); i++) { int f = adj[node][i].first, s = adj[node][i].second; if (f == last) continue; opts.push_back(s + best(f, node)); } sort(opts.begin(), opts.end()); return opts[1]; } #include "crocodile.h" int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { n = N; m = M; for (int i=0; i<m; i++) { int a = R[i][0], b = R[i][1], w = L[i]; adj[a].push_back(make_pair(b, w)); adj[b].push_back(make_pair(a, w)); } int k; cin >> k; for (int i=0; i<k; i++) { int x = P[i]; ter[x] = true; } return best(0, -1); }

Compilation message (stderr)

crocodile.cpp: In function 'int best(int, int)':
crocodile.cpp:16:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<adj[node].size(); i++) {
                ~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...