Submission #569902

#TimeUsernameProblemLanguageResultExecution timeMemory
569902sumit_kk10Swapping Cities (APIO20_swap)C++17
13 / 100
244 ms37568 KiB
#include "swap.h" #include<bits/stdc++.h> #include <vector> #define pb push_back using namespace std; const int N = 1e6 + 5; vector<pair<int, int> > g[N]; int mx, n, m; bool sb2 = 1, sb1 = 1; void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) { n = N; m = M; int wut = 0; map<int, int> mp; for(int i = 0; i < M; ++i){ int u = U[i], v = V[i], w = W[i]; if(u != 0 and v != 0) sb2 = false; g[u].pb({w, v}); g[v].pb({w, u}); mx = max(mx, w); mp[u]++; mp[v]++; } for(int i = 0; i < n; ++i) sort(g[i].begin(), g[i].end()); for(auto k : mp) wut = max(wut, k.second); if(wut > 2) sb1 = false; } int getMinimumFuelCapacity(int X, int Y) { if(sb2 and m == n - 1){ if(n <= 3) return -1; if(X == 0){ int x = g[Y][0].first, xx, dest, mn; if(g[0][0].second != Y){ xx = g[0][0].first; dest = g[0][0].second; }else{ xx = g[0][1].first; dest = g[0][1].second; } if(g[0][1].second != Y and g[0][1].second != dest) mn = g[0][1].first; else mn = g[0][2].first; return max({x, xx, mn}); } int x = g[X][0].first, xx = g[Y][0].first, mn; if(g[0][0].second != X and g[0][0].second != Y) mn = g[0][0].first; else if(g[0][1].second != X and g[0][1].second != Y) mn = g[0][1].first; else mn = g[0][2].first; return max({x, xx, mn}); } if(sb1){ if(m == n - 1) return -1; else return mx; } }

Compilation message (stderr)

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