제출 #1369393

#제출 시각아이디문제언어결과실행 시간메모리
1369393AzeTurk810Team Coding (EGOI24_teamcoding)C++20
0 / 100
446 ms1114112 KiB
/*
Telebe of Adicto && Mamedov yani AzeTurk810
I see humans but no humanity
*/
#include <algorithm>
#include <iostream>
#include <vector>

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using ll = long long;
using namespace std;

#define ln '\n'
#define INFi 1e9
#define INFll 1e18

#ifdef ONPC
#include <algo.hpp>
#else
#define dbg(...)
#define dbg_out(...)
#define myassert(Expr, Msg) ;
#endif

int n, k, ans, res;
vector<vector<int>> adj, mxlvl;
vector<int> pa, colour, inT, outT, lvl, szlvl;
int timer = 0;

inline void systemd() {
    adj.assign(n, vector<int>(0));
    szlvl.assign(n + 1, 0);
    mxlvl.assign(k, vector(n + 1, 0));
    pa.resize(n);
    colour.assign(n, 0);
    inT.resize(n, 0);
    outT.resize(n);
    lvl.assign(n, 0);
}

void dfs1(int v) {
    inT[v] = timer++;
    mxlvl[colour[v]][lvl[v]]++;
    for (auto &u : adj[v]) {
        if (u == pa[v])
            continue;
        lvl[u] = lvl[v] + 1;
        dfs1(u);
    }
    outT[v] = timer;
}

void dfs(int v, int c) {
    szlvl[lvl[v]]++;
    for (auto &u : adj[v]) {
        if (u == pa[v])
            continue;
        dfs(u, c);
    }
    dbg(v);
    if (colour[v] == c)
        res++;
    // res += min(szlvl[lvl[v] + 1], mxlvl[c][lvl[v] + 1]);
}

char solve() {
    if (!(cin >> n >> k))
        return 1;
    systemd();
    vector<int> cnt(k + 1, 0);
    for (int &i : colour) {
        cin >> i;
        cnt[i]++;
    }
    cout << *max_element(cnt.begin(), cnt.end()) << ' ' << 0 << ln;
    return 1;
    for (size_t i = 1; i < n; i++) {
        cin >> pa[i];
        adj[pa[i]].push_back(i);
        adj[i].push_back(pa[i]);
    }
    ans = 1;
    dfs1(0);
    dbg(lvl);
    dbg(colour);
    for (size_t v = 0; v < n; v++) {
        res = 0;
        szlvl.assign(n + 2, 0);
        dfs(v, colour[v]);
        ans = max(ans, res);
    }
    cout << ans << " 0"<< ln;

    return 0;
}

// Attack on titan<3

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int t = 1e9;
    // cin >> t;
    for (int cases = 0; cases < t; cases++) {
        if (solve())
            break;
#ifdef ONPC
        cerr << "__________\n";
#endif
    }
}
// Just Imaginary
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⠀⠀⠀⢀⣴⣾⠀⠀⠀⡀⢀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣦⣾⣿⣿⣿⣿⣿⡆⠁⠀⢀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⡠⠂⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠠⠔⠚⣿⣿⣿⣿⣿⣦⡄⠀⠁⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢀⠠⠐⢂⠉⡀⣀⣤⣄⢻⣿⣿⡟⢈⡹⣿⡀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⡀⠄⠂⠈⠀⣶⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠘⣷⡀⠀⡀⠐⠂⠐⢄
⠀⠀⠀⠀⠀⠀⠀⣿⣿⠟⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣀⣾⣷⠯⠀⠤⠤⠄⠈
⠀⠀⠀⠀⠀⠀⣼⣿⡟⠀⠀⣹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣰⣿⠋⠀⠀⢠⣾⣿⣿⣿⣿⣿⣭⠟⢻⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀
⠀⠀⠀⣀⣶⡟⠁⠀⢾⣶⣿⠟⠉⠈⢻⣿⣿⣿⣦⣜⠀⠛⠛⠿⠁⠀⠀⠀⠀⠀
⠚⠻⠿⠿⡿⠁⠀⢠⣿⣿⠁⠀⣠⠖⠋⠉⠻⣿⣿⣿⣶⡀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣰⣿⡿⠃⠠⠊⠁⠀⠀⠀⠀⠈⢿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⣴⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⣠⣾⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢀⣴⠾⠟⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
*/
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…