Submission #981092

# Submission time Handle Problem Language Result Execution time Memory
981092 2024-05-12T19:23:03 Z vjudge1 Beech Tree (IOI23_beechtree) C++17
0 / 100
1 ms 600 KB
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;

vi beechtree (int n, int m, vi p, vi c) {
    vector <vll> ns(n, vll({}));
    for (ll i = 0; i < n; i++) {
        ll u = p[i];
        while (u != -1) {
            ns[u].push_back(i);
            u = p[u];
        }
    }
    vi ans(n, 1);
    vector <set <ll> > vmst;
    for (ll u = n-1; u >= 0; u--) {
        if (ns[u].size() == 0) continue;
        set <ll> cols;
        for (ll i : ns[u]) {
            if (cols.count(c[i])) ans[u] = 0;
            cols.insert(c[i]);
        }
        if (!ans[u]) ans[0] = 0;
        if (u) vmst.push_back(cols);
    }
    sort(vmst.begin(), vmst.end(), [&](auto a, auto b) {
        return a.size() > b.size();
    });
    for (ll i = 1; i < ll(vmst.size()); i++) {
        set <ll> st1 = vmst[i-1];
        set <ll> st2 = vmst[i];
        for (ll i : st2) ans[0] &= st1.count(i);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -