제출 #1164668

#제출 시각아이디문제언어결과실행 시간메모리
1164668just자매 도시 (APIO20_swap)C++20
0 / 100
0 ms328 KiB
#include "bits/stdc++.h" using namespace std; #define vec vector #define all(x) x.begin(), x.end() int N, M; vec<int> U, V, W; vec<vec<int>> adj; vec<int> weights; map<pair<int,int>, int> edges; int ans = 0; void init(int n, int m, vec<int> u, vec<int> v, vec<int> w) { N = n; M = m; U = u; V = v; W = w; assert(U.size() == M); assert(V.size() == M); assert(W.size() == M); adj.resize(N); for (int i = 0; i < M; i++) { adj[U[i]].push_back(V[i]); adj[V[i]].push_back(U[i]); } weights = W; sort(all(weights)); for (int i = 0; i < M; i++) { edges[{U[i], V[i]}] = W[i]; edges[{V[i], U[i]}] = W[i]; } } int getMinimumFuelCapacity(int x, int y) { if (x > y) swap(x, y); if (N <= 2) return -1; if (x == 0) { int w = edges[{0, y}]; if (w == weights[0]) { return weights[1]; } else { return w; } } else { int a = edges[{0, x}]; int b = edges[{0, y}]; if (a > b) swap(a, b); if (a == weights[0] && b == weights[1]) { return weights[2]; } else { return b; } } } #ifdef debug signed main() {} #endif
#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...