제출 #532867

#제출 시각아이디문제언어결과실행 시간메모리
532867ohohorz자매 도시 (APIO20_swap)C++14
7 / 100
791 ms32724 KiB
#include "swap.h"

#include <vector>
#include<set>
#include<algorithm>
#include<climits>
#include<map>
using namespace std;

// #define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define sz(x) (int)x.size()

const int MAXN = 1e5 + 5;
const int INF = INT_MAX;
const int LOGN = 22;

int n, m;
vector< pair <int,int> > g[MAXN];
multiset<int> wt;
map<pii,int> who;
void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
  n = N,m = M;
  for(int i = 0;i < m;i++){
    int u = U[i] + 1;
    int v = V[i] + 1;
    g[u].pb(mp(v, W[i]));
    wt.insert(W[i]);
    g[v].pb(mp(u, W[i]));
    who[mp(u, v)] = W[i];
    who[mp(v, u)] = W[i];
  }
  
}

int getMinimumFuelCapacity(int X, int Y) {
  X++, Y++;
  if(sz(g[1]) < 3) return -1;
  if(X==1){
    int w = who[mp(X, Y)];
    int ans = w;
    wt.erase(wt.find(w));
    int w2 = *(wt.begin());
    ans = max(ans, w2);
    wt.erase(wt.find(w2));
    
    int w3 = *(wt.begin());
    ans = max(ans, w3);
    wt.insert(w);
    wt.insert(w2);
    return ans;
  }
  int w = who[mp(X, 1)];
  int ans = w;
  int w2 = who[mp(Y, 1)];
  ans = max(ans, w2);
  wt.erase(wt.find(w));
  wt.erase(wt.find(w2));
  ans = max(ans, *(wt.begin()));
  wt.insert(w);
  wt.insert(w2);
  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...