답안 #1010141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010141 2024-06-28T11:18:52 Z nickolasarapidis 봉쇄 시간 (IOI23_closing) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "closing.h"
using namespace std;

#define ll long long

const int MAXN = 200000;

vector<pair<int, int> > adj[MAXN];

map<ll, int> m;

int ans = 2;

void dfsPrecompute(int s, int e, vector<ll> dis){
	for(auto u : adj[s]){
		if(u.first != e){
			dfsPrecompute(u.first, s, dis);
			dis[u.first] = dis[s] + u.second;
		}
	}
}

void dfs(int s, int e, vector<ll> C, vector<ll> dis){
	ans++;
	for(auto u : adj[s]){
		if(u.first != e and dis[u.first] <= C[u.first]){
			dfs(u.first, s, C, dis);
		}
	}
}

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W){
	for(int i = 0; i < N - 1; i++){
		adj[U[i]].push_back({V[i], W[i]});
		adj[V[i]].push_back({U[i], W[i]});
	}

	vector<ll> disX(N);
	vector<ll> disY(N);

	vector<ll> dis(N);
	vector<ll> large(N);

	vector<ll> C(N, 0);

	disX[X] = 0;
	disY[Y] = 0;

	ll sum = 0;

	dfsPrecompute(X, -1, disX);
	dfsPrecompute(Y, -1, disY);

	for(int i = 0; i < N; i++){
		dis[i] = min(disX[i], disY[i]);
		m[dis[i]] = i;
		large[i] = max(disX[i], disY[i]);
	}

	sort(dis.begin(), dis.end());

	for(int i = 2; i < N; i++){
		if(sum += dis[i] <= K){
			if(sum += large[m[dis[i]]] <= K){
				C[i] = large[m[dis[i]];
			}
			else{
				C[i] = dis[i];
			}
		}
		else{
			break;
		}
	}

	dfs(X, -1, C, dis);
	dfs(Y, -1, C, dis);

	return ans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:66:27: error: expected ']' before ';' token
   66 |     C[i] = large[m[dis[i]];
      |                           ^
      |                           ]