답안 #979500

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979500 2024-05-11T06:45:50 Z ducksaysquack 자매 도시 (APIO20_swap) C++17
컴파일 오류
0 ms 0 KB
#include "swap.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
int n;
vector<pair<int,pair<int,int>>> e;
vector<int> to(1e5+5);
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
	n = N, m = M;
	for(int i=0;i<m;i++) {e.pb({W[i],{U[i],V[i]}}); to[V[i]] = W[i];}
	sort(begin(e),end(e));
}
int getMinimumFuelCapacity(int x, int y) {
	if(n <= 3) return -1;
	if(x > y) swap(x,y);
	if(x == 0) {
		int cnt = 0, mx = to[y];
		for(int i=0;i<m;i++) if(e[i].s.s != y) {
			cnt++, mx = max(mx, e[i].f);
			if(cnt >= 2) return mx;
		}
	}
	else for(int i=0;i<m;i++) if(e[i].s.s != x && e[i].s.s != y) return max(to[x], to[y], e[i].f);
}

Compilation message

swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:11:9: error: 'm' was not declared in this scope
   11 |  n = N, m = M;
      |         ^
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:20:17: error: 'm' was not declared in this scope
   20 |   for(int i=0;i<m;i++) if(e[i].s.s != y) {
      |                 ^
swap.cpp:25:21: error: 'm' was not declared in this scope
   25 |  else for(int i=0;i<m;i++) if(e[i].s.s != x && e[i].s.s != y) return max(to[x], to[y], e[i].f);
      |                     ^
In file included from /usr/include/c++/10/vector:60,
                 from swap.h:1,
                 from swap.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
swap.cpp:25:94:   required from here
/usr/include/c++/10/bits/stl_algobase.h:303:17: error: '__comp' cannot be used as a function
  303 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~