QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#138528#5455. TreeScriptammardab3an#WA 1ms3544kbC++17786b2023-08-11 21:30:082023-08-11 21:30:10

Judging History

This is the latest submission verdict.

  • [2023-08-11 21:30:10]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3544kb
  • [2023-08-11 21:30:08]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main(){

    int t;
    cin >> t;

    while(t--){

        int n;
        cin >> n;

        vector<pair<int, int>> v(n);

        for(int i = 0; i < n; i++){
            int prev;
            cin >> prev;
            prev--;
            if(prev != -1) v[prev].second = i-1;
            v[i] = {i, i};
        }

        vector<int> pre(n+3, 0);
        for(int i = 0; i < n; i++){
            auto [f, s] = v[i];
            pre[f]++;
            pre[s+1]--;
        }

        int ans = 0;
        for(int i = 0; i <= n; i++){
            if(i)
            pre[i] += pre[i-1];
            ans = max(ans, pre[i]);
        }

        cout << ans << endl;

    }

}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3544kb

input:

2
3
0 1 2
7
0 1 2 2 1 4 1

output:

1
3

result:

wrong answer 2nd numbers differ - expected: '2', found: '3'