Submission #569752

# Submission time Handle Problem Language Result Execution time Memory
569752 2022-05-27T17:47:09 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
const int N = 1e6 + 5;
vector<pair<int, int> > g[N];
int mx, n, m;


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];
		g[u].pb({v, w});
		g[v].pb({u, w});
		mx = max(mx, w);
	}
}

int getMinimumFuelCapacity(int X, int Y) {
	if(m == n - 1)
		return -1;
	else
		return mx;
}

Compilation message

swap.cpp:6:1: error: 'vector' does not name a type
    6 | vector<pair<int, int> > g[N];
      | ^~~~~~
swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:16:3: error: 'g' was not declared in this scope
   16 |   g[u].pb({v, w});
      |   ^
swap.cpp:18:8: error: 'max' was not declared in this scope; did you mean 'std::max'?
   18 |   mx = max(mx, w);
      |        ^~~
      |        std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from swap.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~