Submission #1029875

# Submission time Handle Problem Language Result Execution time Memory
1029875 2024-07-21T13:05:03 Z Mr_Husanboy Beech Tree (IOI23_beechtree) C++17
0 / 100
1 ms 440 KB
#include "beechtree.h"
#include <bits/stdc++.h>


#ifdef LOCAL
#include "debugger.cpp"
#else
#define debug(...)
#endif

using namespace std;

#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
#define ll long long

template<typename T>
int len(T &a){
    return a.size();
}

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

vector<int> beechtree(int n, int m, std::vector<int> par, std::vector<int> col)
{
    vector<vector<int>> g(n);
    for(int i = 1; i < n; i ++){
        g[par[i]].push_back(i);
        col[i] --;
    }



    vector<int> cnt(m + 1);
    vector<int> res(n);
    bool ok = 1;
    set<int> al;
    vector<int> occ(n + 1);
    for(int i = 1; i < n; i ++) cnt[col[i]] ++, al.insert(col[i]);

    for(int i = 1; i < n; i ++){
        set<int> st;
        for(auto u : g[i]){
            st.insert(col[u]);
        }
        if(len(st) == len(g[i])){
            res[i] = 1;
        }else{
            ok = 0;
        }
    }
    if(!ok){
        return res;
    }
    set<int> st;
    int c = 0;
    for(auto u : g[0]){
        st.insert(col[u]);
        if(len(g[u])){
            c ++;
            occ[cnt[u]] ++;
            //cout << cnt[u] << ' ' << u + 1 << endl;
        }
    }   
    if(len(st) != len(g[0]) || len(st) != len(al)){
        return res;
    }

    if(*max_element(all(occ)) > 2){
        return res;
    }
    cout << c << endl;
    for(int i = 1; i <= c; i ++){
        if(occ[c] > 1) return res;
    }

    res[0] = 1;
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Possible tampering with the output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 1 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 0 ms 348 KB Possible tampering with the output
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 344 KB Possible tampering with the output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
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 344 KB Possible tampering with the output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
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 344 KB Possible tampering with the output
3 Halted 0 ms 0 KB -