QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#206412#6438. Crystalflywiseman123Compile Error//C++14965b2023-10-07 20:23:512023-10-07 20:23:51

Judging History

你现在查看的是最新测评结果

  • [2023-10-07 20:23:51]
  • 评测
  • [2023-10-07 20:23:51]
  • 提交

answer

vector<int>g[MAXN];
int n,u, v;
int a[MAXN];
int f[MAXN], sum[MAXN], t[MAXN];
void dfs(int u,int fa) {
	int mx = 0;
	multiset<int>st;//维护t[v] = 3的点的最大值
	for (int v : g[u]) {
		if (v == fa)continue;
		dfs(v, u);
		sum[u] += f[v];
		mx = max(mx, a[v]);//找到a[v]的最大值
		if (t[v] == 3)st.insert(a[v]);//把t[v] = 3 的点放进来
	}
	f[u] = sum[u] + mx;
	st.insert(-INF);
	for (int v : g[u]) {
		if (v == fa)continue;
		if (t[v] == 3)st.erase(st.find(a[v]));
		f[u] = max(f[u],sum[u] - f[v] + a[v] + sum[v] + *st.rbegin());
		if (t[v] == 3)st.insert(a[v]);//注意不要忘了添加回去
	}
}
void slove() {
	cin >> n;
	for (int i = 1; i <= n; i++)g[i].clear(), f[i] = sum[i] = 0;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = 1; i <= n; i++)cin >> t[i];
	for (int i = 1; i <= n - 1; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, 0);
	cout << f[1] + a[1] << endl;
}

Details

answer.code:1:1: error: ‘vector’ does not name a type
    1 | vector<int>g[MAXN];
      | ^~~~~~
answer.code:3:7: error: ‘MAXN’ was not declared in this scope
    3 | int a[MAXN];
      |       ^~~~
answer.code:4:7: error: ‘MAXN’ was not declared in this scope
    4 | int f[MAXN], sum[MAXN], t[MAXN];
      |       ^~~~
answer.code:4:18: error: ‘MAXN’ was not declared in this scope
    4 | int f[MAXN], sum[MAXN], t[MAXN];
      |                  ^~~~
answer.code:4:27: error: ‘MAXN’ was not declared in this scope
    4 | int f[MAXN], sum[MAXN], t[MAXN];
      |                           ^~~~
answer.code: In function ‘void dfs(int, int)’:
answer.code:7:9: error: ‘multiset’ was not declared in this scope
    7 |         multiset<int>st;//维护t[v] = 3的点的最大值
      |         ^~~~~~~~
answer.code:7:18: error: expected primary-expression before ‘int’
    7 |         multiset<int>st;//维护t[v] = 3的点的最大值
      |                  ^~~
answer.code:8:22: error: ‘g’ was not declared in this scope
    8 |         for (int v : g[u]) {
      |                      ^
answer.code:11:17: error: ‘sum’ was not declared in this scope
   11 |                 sum[u] += f[v];
      |                 ^~~
answer.code:11:27: error: ‘f’ was not declared in this scope
   11 |                 sum[u] += f[v];
      |                           ^
answer.code:12:30: error: ‘a’ was not declared in this scope
   12 |                 mx = max(mx, a[v]);//找到a[v]的最大值
      |                              ^
answer.code:12:22: error: ‘max’ was not declared in this scope; did you mean ‘mx’?
   12 |                 mx = max(mx, a[v]);//找到a[v]的最大值
      |                      ^~~
      |                      mx
answer.code:13:21: error: ‘t’ was not declared in this scope
   13 |                 if (t[v] == 3)st.insert(a[v]);//把t[v] = 3 的点放进来
      |                     ^
answer.code:13:31: error: ‘st’ was not declared in this scope; did you mean ‘std’?
   13 |                 if (t[v] == 3)st.insert(a[v]);//把t[v] = 3 的点放进来
      |                               ^~
      |                               std
answer.code:15:9: error: ‘f’ was not declared in this scope
   15 |         f[u] = sum[u] + mx;
      |         ^
answer.code:15:16: error: ‘sum’ was not declared in this scope
   15 |         f[u] = sum[u] + mx;
      |                ^~~
answer.code:16:9: error: ‘st’ was not declared in this scope; did you mean ‘std’?
   16 |         st.insert(-INF);
      |         ^~
      |         std
answer.code:16:20: error: ‘INF’ was not declared in this scope
   16 |         st.insert(-INF);
      |                    ^~~
answer.code:17:22: error: ‘g’ was not declared in this scope
   17 |         for (int v : g[u]) {
      |                      ^
answer.code:19:21: error: ‘t’ was not declared in this scope
   19 |                 if (t[v] == 3)st.erase(st.find(a[v]));
      |                     ^
answer.code:19:48: error: ‘a’ was not declared in this scope
   19 |                 if (t[v] == 3)st.erase(st.find(a[v]));
      |                                                ^
answer.code:20:49: error: ‘a’ was not declared in this scope
   20 |                 f[u] = max(f[u],sum[u] - f[v] + a[v] + sum[v] + *st.rbegin());
      |                                                 ^
answer.code:20:24: error: ‘max’ was not declared in this scope; did you mean ‘mx’?
   20 |                 f[u] = max(f[u],sum[u] - f[v] + a[v] + sum[v] + *st.rbegin());
      |                        ^~~
      |                        mx
answer.code:21:21: error: ‘t’ was not declared in this scope
   21 |                 if (t[v] == 3)st.insert(a[v]);//注意不要忘了添加回去
      |                     ^
answer.code: In function ‘void slove()’:
answer.code:25:9: error: ‘cin’ was not declared in this scope
   25 |         cin >> n;
      |         ^~~
answer.code:26:37: error: ‘g’ was not declared in this scope
   26 |         for (int i = 1; i <= n; i++)g[i].clear(), f[i] = sum[i] = 0;
      |                                     ^
answer.code:26:51: error: ‘f’ was not declared in this scope
   26 |         for (int i = 1; i <= n; i++)g[i].clear(), f[i] = sum[i] = 0;
      |                                                   ^
answer.code:26:58: error: ‘sum’ was not declared in this scope
   26 |         for (int i = 1; i <= n; i++)g[i].clear(), f[i] = sum[i] = 0;
      |                                                          ^~~
answer.code:27:44: error: ‘a’ was not declared in this scope
   27 |         for (int i = 1; i <= n; i++)cin >> a[i];
      |                                            ^
answer.code:28:44: error: ‘t’ was not declared in this scope
   28 |         for (int i = 1; i <= n; i++)cin >> t[i];
      |                                            ^
answer.code:31:17: error: ‘g’ was not declared in this scope
   31 |                 g[u].push_back(v);
      |                 ^
answer.code:35:9: error: ‘cout’ was not declared in this scope
   35 |         cout << f[1] + a[1] << endl;
  ...