Submission #532866

# Submission time Handle Problem Language Result Execution time Memory
532866 2022-03-04T06:22:06 Z ohohorz Swapping Cities (APIO20_swap) C++14
Compilation error
0 ms 0 KB
#include "swap.h"

#include <vector>
#include<set>
#include<algorithm>
#include<climits>
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;
}

Compilation message

swap.cpp:22:1: error: 'map' does not name a type; did you mean 'mp'?
   22 | map<pii,int> who;
      | ^~~
      | mp
swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:31:5: error: 'who' was not declared in this scope
   31 |     who[mp(u, v)] = W[i];
      |     ^~~
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:41:13: error: 'who' was not declared in this scope
   41 |     int w = who[mp(X, Y)];
      |             ^~~
swap.cpp:54:11: error: 'who' was not declared in this scope
   54 |   int w = who[mp(X, 1)];
      |           ^~~