# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977601 | 2024-05-08T07:29:31 Z | Ning07 | Swapping Cities (APIO20_swap) | C++17 | 0 ms | 0 KB |
#include "swap.h" #include <vector> #include<bits/stdc++.h> using namespace std; #define L(i, j, k) for (int i = (j); i <= k; i++) #define R(i, j, k) for (int i = (j); i >= k; i--) int N, M; int ok = true; int mx = -1; vector<vector<pair<int, int>>> adj; void init(int _N, int _M, std::vector<int> _U, std::vector<int> _V, std::vector<int> _W) { N = _N; M = _M; adj.resize(N); for (int i = 0; i < M; i++) { G[_U[i]].push_back(make_pair(_V[i], _W[i])); G[_V[i]].push_back(make_pair(_U[i], _W[i])); mx = max(mx, _W[i]); } for (int i = 0; i < N; i++) if (adj[i].size() <= 1) ok = false; } int getMinimumFuelCapacity(int X, int Y) { if (!ok) return -1; return mx; }