QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#584771#9184. Team Codingchengning0909Compile Error//C++20680b2024-09-23 16:41:162024-09-23 16:41:17

Judging History

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

  • [2024-09-23 16:41:17]
  • 评测
  • [2024-09-23 16:41:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

int n, k, a[N], dep[N];
vector<int> g[N];
bool flag = 1;

void dfs(int u) {
    for (int v : g[u]) dfs(v);

}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 2, fa; i <= n; i++) {
        cin >> fa, fa++, g[fa].push_back(i);
        flag &= fa == i - 1;
    }
    if (flag) {
        for (int i = n; i >= 1; i--) {
            cnt[a[i]]++;
            ans = max(ans, cnt[a[i]]);
        }
        cout << ans << " 0";
    } else if (n <= 2000) {
        dfs(1);
    }
    return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:26:13: error: ‘cnt’ was not declared in this scope; did you mean ‘int’?
   26 |             cnt[a[i]]++;
      |             ^~~
      |             int
answer.code:27:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   27 |             ans = max(ans, cnt[a[i]]);
      |             ^~~
      |             abs
answer.code:29:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   29 |         cout << ans << " 0";
      |                 ^~~
      |                 abs