답안 #660163

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660163 2022-11-20T15:22:51 Z Trisanu_Das 꿈 (IOI13_dreaming) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#include "dreaming.h"
 
vector<array<int, 2>> adj[100000];
int a[100000], b, x, y, ans = -1;
bitset<MAXN> vis;
 
void dfs(int u, int d, int p = -1){
	vis[u] = 1;
	a[u] = max(a[u], d);
	if(d > x) x = d, y = u;
	if(d < 0) b = min(b, a[u]);
	for(auto &v : adj[u]) if(v[0] != p) dfs(v[0], d < 0 ? d : d + v[1], u);
}
 
int travelTime(int n, int m, int L, int A[], int B[], int T[]){
	for(int i = 0; i < m; i++){
		adj[A[i]].push_back({B[i], T[i]});
		adj[B[i]].push_back({A[i], T[i]});
	}
	priority_queue<int> pq;
	for(int i = 0; i < n; i++){
		if(vis[i]) continue;
		x = y = -1, b = INT_MAX;
		dfs(i, 0); dfs(y, 0); dfs(y, 0);
		ans = max(ans, x);
		dfs(i, -1);
		q.push(-b);
		while(q.size() > 3) q.pop();
	}
	int op3 = -q.top(); q.pop();
	if(q.empty()) return ans;
	int op2 = -q.top(); q.pop();
	if(q.empty()) return max(ans, op2 + op3 + L);
	int op1 = -q.top(); q.pop();
	return max(ans, max(op1 + op2 + L, op2 + op3 + L + L));
}

Compilation message

dreaming.cpp:7:8: error: 'MAXN' was not declared in this scope
    7 | bitset<MAXN> vis;
      |        ^~~~
dreaming.cpp:7:12: error: template argument 1 is invalid
    7 | bitset<MAXN> vis;
      |            ^
dreaming.cpp: In function 'void dfs(int, int, int)':
dreaming.cpp:10:5: error: invalid types 'int[int]' for array subscript
   10 |  vis[u] = 1;
      |     ^
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:24:9: error: invalid types 'int[int]' for array subscript
   24 |   if(vis[i]) continue;
      |         ^
dreaming.cpp:29:3: error: 'q' was not declared in this scope
   29 |   q.push(-b);
      |   ^
dreaming.cpp:32:13: error: 'q' was not declared in this scope; did you mean 'pq'?
   32 |  int op3 = -q.top(); q.pop();
      |             ^
      |             pq