Submission #569754

# Submission time Handle Problem Language Result Execution time Memory
569754 2022-05-27T17:54:39 Z sumit_kk10 Swapping Cities (APIO20_swap) C++17
Compilation error
0 ms 0 KB
#include "swap.h"
#include<bits/stdc++.h>
#include <vector>
#define pb push_back
using namespace std;
const int N = 1e6 + 5;
vector<pair<int, int> > g[N];
int mx, n, m;
bool sb2 = 1;

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], v = V[i], w = W[i];
		if(u != 0)
			sb2 = false;
		g[u].pb({v, w});
		g[v].pb({u, w});
		mx = max(mx, w);
	}
}
 
int getMinimumFuelCapacity(int X, int Y) {
	if(sb2 and m == n - 1){
		int x = g[X][0].second, xx = g[Y][0].second, mn = INT_MAX;
		for(auto k : g[0]){
			if(k.first != X and k.first != Y) 
				mn = min(mn, k.second) 
		}
		if(mn == INT_MAX) return -1;
		return max({x, xx, mn});
	}
	if(m == n - 1)
		return -1;
	else
		return mx;
}

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:30:27: error: expected ';' before '}' token
   30 |     mn = min(mn, k.second)
      |                           ^
      |                           ;
   31 |   }
      |   ~