답안 #937595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937595 2024-03-04T09:30:54 Z IBory 자매 도시 (APIO20_swap) C++17
컴파일 오류
0 ms 0 KB
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;

const int MAX = 200007;
int N, M, R[MAX], D[MAX];
bool T[MAX], isLine;
tuple<int, int, int> E[MAX];

void init(int _N, int _M, vector<int> U, vector<int> V, vector<int> W) {
	N = _N, M = _M;
	for (int i = 1; i <= M; ++i) {
		E[i] = {U[i], V[i], W[i]};
		D[U[i]]++;
		D[V[i]]++;
	}
	if (_N == _M + 1 && *max_element(D, D + MAX) == 2) isLine = 1;
	sort(E + 1, E + M + 1);
}

void Clear() {
	iota(R, R + MAX, 0);
	memset(T, 0, sizeof(T));
	memset(D, 0, sizeof(D));
}

int Find(int n) {
	if (n == R[n]) return n;
	int r = Find(R[n]);
	T[r] |= T[R[n]];
	return R[n] = r;
}

void Union(int a, int b) {
	if (++D[a] == 3) T[a] = 1;
	if (++D[b] == 3) T[b] = 1;
	a = Find(a), b = Find(b);
	if (a == b) return;
	R[a] = b;
	T[b] |= T[a];
}

int getMinimumFuelCapacity(int x, int y) {
	if (isLine) return -1;

	int l = 1, r = M + 1;
	while (l + 1 < r) {
		int mid = (l + r) >> 1;

		Clear();
		for (int i = 1; i <= mid; ++i) {
			auto [_, a, b] =E[i];
			Union(a, b);
		}

		bool ok = (Find(x) == Find(y)) && T[Find(x)];
		(ok ? R : L) = mid;
	}

	auto [ans, a, b] = E[L];
	return ans;
}

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:57:13: error: 'L' was not declared in this scope
   57 |   (ok ? R : L) = mid;
      |             ^
swap.cpp:60:23: error: 'L' was not declared in this scope
   60 |  auto [ans, a, b] = E[L];
      |                       ^