Submission #397830

#TimeUsernameProblemLanguageResultExecution timeMemory
397830yuto1115Swapping Cities (APIO20_swap)C++17
7 / 100
146 ms15760 KiB
#include "swap.h" #include <bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int inf = 1001001001; namespace { int n; vvp G; } void init(int _n, int m, vi u, vi v, vi w) { n = _n; G.resize(n); rep(i, m) { G[u[i]].eb(v[i], w[i]); G[v[i]].eb(u[i], w[i]); } sort(all(G[0]), [](P a, P b) { return a.second < b.second; }); } // subtask 2 int getMinimumFuelCapacity(int x, int y) { if (n <= 3) return -1; if (x == 0) { int ans = G[y][0].second; int cnt = 0; for (auto[v, w] : G[0]) { if (v == y) continue; chmax(ans, w); cnt++; if (cnt == 2) break; } return ans; } else { int ans = max(G[x][0].second, G[y][0].second); for (auto[v, w] : G[0]) { if (v == x or v == y) continue; chmax(ans, w); break; } return ans; } }
#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...