Submission #802744

#TimeUsernameProblemLanguageResultExecution timeMemory
802744radaiosm7Swapping Cities (APIO20_swap)C++11
7 / 100
82 ms10824 KiB
#include "swap.h" #include <bits/stdc++.h> using namespace std; int i, n; bool visited[100005]; int we[100005]; pair<int, int> tw[100005]; bool cycle; void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) { n = N; for (i=0; i < M; ++i) tw[i] = make_pair(W[i], V[i]); sort(tw, tw+M); for (i=0; i < M; ++i) we[V[i]] = W[i]; } int getMinimumFuelCapacity(int X, int Y) { if (n <= 3) return -1; if (X == 0) { int cc = 0; int ans = we[Y]; for (i=0; i < 3; ++i) { if (tw[i].second == Y) continue; ++cc; ans = max(ans, tw[i].first); if (cc == 2) return ans; } } else for (i=0; i < 3; ++i) if (tw[i].second != X && tw[i].second != Y) return max({we[X], we[Y], tw[i].first}); }

Compilation message (stderr)

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^
#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...