답안 #866091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866091 2023-10-25T11:55:17 Z vjudge1 봉쇄 시간 (IOI23_closing) C++17
컴파일 오류
0 ms 0 KB
#include "closing.h"

#include <vector>
const int MAXN = 2e5 + 3;
vector<int> adj[MAXN];
int dep1[MAXN];
int dep2[MAXN];
void dfs(int node, int par, int dep[]){
	for (auto [to, w] : adj[node]){
		if (to == par) continue;
		dep[to] = dep[node] + w;
	}
}
int max_score(int N, int X, int Y, long long 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]});
	}
	dfs(X, -1, dep1);
	dfs(Y, -1, dep2);
	priority_queue<int, vector<int>, greater<int>> pq;
	for (int i = 0; i < N-1; i++){
		pq.push(dep1[i]);
		pq.push(dep2[i]);
	}
	int ans = 0;
	while (!pq.empty && pq.top() <= K){
		K -= pq.top();
		pq.pop();
		ans++;
	}
	return ans;
}

Compilation message

closing.cpp:5:1: error: 'vector' does not name a type
    5 | vector<int> adj[MAXN];
      | ^~~~~~
closing.cpp: In function 'void dfs(int, int, int*)':
closing.cpp:9:22: error: 'adj' was not declared in this scope
    9 |  for (auto [to, w] : adj[node]){
      |                      ^~~
closing.cpp: At global scope:
closing.cpp:14:49: error: 'vector' has not been declared
   14 | int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W)
      |                                                 ^~~~~~
closing.cpp:14:55: error: expected ',' or '...' before '<' token
   14 | int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W)
      |                                                       ^
closing.cpp: In function 'int max_score(int, int, int, long long int, int)':
closing.cpp:17:3: error: 'adj' was not declared in this scope
   17 |   adj[U[i]].push_back({V[i], W[i]});
      |   ^~~
closing.cpp:17:7: error: 'U' was not declared in this scope
   17 |   adj[U[i]].push_back({V[i], W[i]});
      |       ^
closing.cpp:17:24: error: 'V' was not declared in this scope
   17 |   adj[U[i]].push_back({V[i], W[i]});
      |                        ^
closing.cpp:17:30: error: 'W' was not declared in this scope
   17 |   adj[U[i]].push_back({V[i], W[i]});
      |                              ^
closing.cpp:22:2: error: 'priority_queue' was not declared in this scope
   22 |  priority_queue<int, vector<int>, greater<int>> pq;
      |  ^~~~~~~~~~~~~~
closing.cpp:22:17: error: expected primary-expression before 'int'
   22 |  priority_queue<int, vector<int>, greater<int>> pq;
      |                 ^~~
closing.cpp:24:3: error: 'pq' was not declared in this scope
   24 |   pq.push(dep1[i]);
      |   ^~
closing.cpp:28:10: error: 'pq' was not declared in this scope
   28 |  while (!pq.empty && pq.top() <= K){
      |          ^~