Submission #981095

# Submission time Handle Problem Language Result Execution time Memory
981095 2024-05-12T19:26:45 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];
        if (u != -1) {
            ns[u].push_back(i);
        }
    }
    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]) {
            // cerr << c[i] << ' ';
            if (cols.count(c[i])) ans[u] = 0;
            cols.insert(c[i]);
        }
        // cerr << endl;
        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 600 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -