QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#260738#6638. Treelectionucup-team1198#WA 39ms6084kbC++20778b2023-11-22 14:38:592023-11-22 14:39:00

Judging History

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

  • [2023-11-22 14:39:00]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:6084kb
  • [2023-11-22 14:38:59]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()

const int MAXN = 1e6 + 100;
int par[MAXN];
int sz[MAXN];

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i < n; ++i) {
        cin >> par[i];
        par[i]--;
    }
    fill(sz, sz + n, 1);
    string ans(n, '-');
    for (int i = n - 1; i >= 0; --i) {
        if (2 * (sz[i] - 1) > n - 1) {
            ans[i] = '1';
        } else {
            ans[i] = '0';
        }
        sz[par[i]] += sz[i];
    }
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int tst;
    cin >> tst;
    while (tst--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5856kb

input:

2
4
1 2 3
5
1 1 2 2

output:

1100
10000

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 39ms
memory: 6084kb

input:

10
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

wrong answer 1st lines differ - expected: '111111111111111111111111111111...0000000000000000000000000000000', found: '111111111111111111111111111111...0000000000000000000000000000000'