Submission #1066702

# Submission time Handle Problem Language Result Execution time Memory
1066702 2024-08-20T05:07:34 Z LittleOrange Beech Tree (IOI23_beechtree) C++17
0 / 100
0 ms 348 KB
#include "beechtree.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
    ll n = N;
    ll m = M;
    vector<vector<ll>> ch(n);
    for(ll i = 1;i<n;i++) ch[P[i]].push_back(i);
    vector<ll> ord;
    {
        function<void(ll)> dfs;
        dfs = [&](ll i){
            ord.push_back(i);
            for(ll j : ch[i]) dfs(j);
        };
        dfs(0);
    }
    vector<ll> rord = ord;
    reverse(rord.begin(),rord.end());
    vector<ll> bad(n,0);
    for(ll i : rord){
        vector<ll> v;
        for(ll j : ch[i]){
            if (bad[j]) bad[i] = 1;
            v.push_back(C[j]);
        }
        sort(v.begin(),v.end());
        if (unique(v.begin(),v.end())!=v.end()) bad[i] = 1;
    }
    vector<ll> ans(n);
    for(ll i = 0;i<n;i++) ans[i] = !bad[i];
    return ans;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:8:8: warning: unused variable 'm' [-Wunused-variable]
    8 |     ll m = M;
      |        ^
# 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 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 Incorrect 0 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 Incorrect 0 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 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 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 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 Incorrect 0 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 Incorrect 0 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 Incorrect 0 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 Incorrect 0 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 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -