제출 #387174

#제출 시각아이디문제언어결과실행 시간메모리
387174talant117408자매 도시 (APIO20_swap)C++17
13 / 100
524 ms20576 KiB
#include "swap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) int((v).size()) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define OK cout << "OK" << endl; const int N = 1e5+7; vector <pii> graph[N]; int mx; multiset <int> st; bool less3 = 1, less2 = 0; void init(int n, int m, vector<int> U, vector<int> V, vector<int> W) { for (int i = 0; i < m; i++) { graph[U[i]].pb(mp(V[i], W[i])); graph[V[i]].pb(mp(U[i], W[i])); } for (int i = 0; i < n; i++) { sort(all(graph[i])); if (sz(graph[i]) > 2) less3 = 0; } for (auto to : W) st.insert(to); if (less3) { for (int i = 0; i < n; i++) { if (sz(graph[i]) == 1) less2 = 1; } if (!less2) mx = *max_element(all(W)); } } int getMinimumFuelCapacity(int X, int Y) { if (less3) { if (less2) return -1; return mx; } else { if (!X || !Y) { int a = (*lb(all(graph[0]), mp(max(X, Y), 0))).second; st.erase(st.find(a)); int b = *st.begin(); st.erase(st.begin()); int c = *st.begin(); st.insert(a); st.insert(b); return max({a, b, c}); } else { int a = (*lb(all(graph[0]), mp(X, 0))).second, b = (*lb(all(graph[0]), mp(Y, 0))).second; st.erase(st.find(a)); st.erase(st.find(b)); int c = *st.begin(); st.insert(a); st.insert(b); return max(c, max(a, b)); } } }
#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...