답안 #1031546

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031546 2024-07-23T00:36:23 Z aaaaaarroz 참나무 (IOI23_beechtree) C++17
17 / 100
98 ms 63168 KB
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> t, depth;
vector<vector<int>> ch;
vector<set<int>> ch_colors;
bool orden(int x, int y){
	if (ch_colors[x].size() != ch_colors[y].size())
            return ch_colors[x].size() < ch_colors[y].size();
        return x > y;
}
void dfs(int u){
    for (int v : ch[u]){
        dfs(v);
        depth[u] = max(depth[u], depth[v] + 1);
        if (t[v] == 0)
            t[u] = 0;
    }
    if (depth[u] != 2){
        if (depth[u] > 2)
            t[u] = 0;
        return;
    }
    vector<int> ord = ch[u];
    ord.push_back(u);
    sort(ord.begin(), ord.end(),orden);
    if (ord.back() != u)
        t[u] = 0;
    for (int i = 0; i + 1 < (int)ord.size(); ++i)
    {
        int x = ord[i], y = ord[i + 1];
        for (int c : ch_colors[x])
        {
            if (!ch_colors[y].count(c))
                t[u] = 0;
        }
    }
}
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C){
    t.assign(N, 1);
    ch.assign(N, {});
    ch_colors.resize(N);
    for (int v = 1; v < N; ++v){
        int u = P[v], c = C[v];
        if (ch_colors[u].count(c))
            t[u] = false;
        ch[u].push_back(v);
        ch_colors[u].insert(c);
    }
    depth.assign(N, 0);
    dfs(0);
    return t;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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: '1', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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: '1', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 436 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 42 ms 16880 KB Output is correct
16 Correct 40 ms 15988 KB Output is correct
17 Correct 39 ms 16216 KB Output is correct
18 Correct 45 ms 16588 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 85 ms 63028 KB Output is correct
6 Correct 82 ms 63168 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 700 KB Output is correct
11 Correct 71 ms 34644 KB Output is correct
12 Correct 98 ms 30216 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
7 Halted 0 ms 0 KB -