# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1058100 | 2024-08-14T08:27:12 Z | Ignut | 참나무 (IOI23_beechtree) | C++17 | 82 ms | 19656 KB |
/* Ignut started: 14.08.2024 now: 14.08.2024 ████████████████████████████████████████████████████████████████████ ████████████████████████████████ ████████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████ ██████████████████ ██████████████████ ██████ ██████ ██████████████ ██████████████ ██████ ██████ ██ ████████████ ████████████ ██ ██████ ██████ ████ ██████████ ██████████ ████ ██████ ██████ ████ ██████████ ██████████ ████ ██████ ██████ ████ ██████████ ██████████ ██████ ██████ ██████ ██████ ██████████ ██████████ ██████ ██████ ██████ ██████ ████████ ████████ ██████ ██████ ██████ ██████ ██████ ██████ ██████ ██████ ██████ ████ ████ ████ ████ ██████ ██████ ██████████ ████ ██████████ ██████ ██████ ██ ██████ ████████ ██████ ██ ██████ ██████ ██████ ████████ ██████ ██████ ██████ ██ ██ ██████ ██████████████████████ ████ ████ ██████████████████████ ████████████████████████ ██ ██ ████████████████████████ ██████████████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ████████████████████████████████████████████████████████████████████ */ #include <bits/stdc++.h> using namespace std; using ll = long long; const int MAXN = 2e5 + 123; int n; vector<int> tree[MAXN]; vector<int> p; vector<int> c; vector<int> res; int cnt[MAXN] = {}; bool Check(vector<int> &lst, int root) { // if (root == 4) { // cout << root << " :\n"; // } sort(lst.begin(), lst.end()); do { bool ok = true; for (int v : lst) { int par = cnt[c[v]]; int vert = (par == 0 ? root : lst[par - 1]); // if (root == 4) { // cout << v << " -> " << par << ", "; // } if (p[v] != vert) { ok = false; break; } cnt[c[v]] ++; } // if (root == 4) { // cout << '\n'; // } for (int v : lst) cnt[c[v]] = 0; if (ok) return true; } while (next_permutation(lst.begin(), lst.end())); return false; } vector<int> dfs(int v) { vector<int> lst = {}; for (int to : tree[v]) if (to != p[v]) for (int u : dfs(to)) lst.push_back(u); res[v] |= Check(lst, v); lst.push_back(v); return lst; } vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) { n = N; p = P; c = C; res.assign(N, 0); if (N <= 8) { // cout << "brute\n"; for (int i = 1; i < N; i ++) { tree[i].push_back(P[i]); tree[P[i]].push_back(i); } dfs(0); return res; } vector<int> v1, v2; for (int i = 1; i < N; i ++) { if (p[i] == 0) v1.push_back(i); else v2.push_back(i); res[i] = 1; } set<int> st; for (int v : v1) { st.insert(c[v]); } if (st.size() != v1.size()) return res; set<int> st2; for (int v : v2) st2.insert(c[v]); if (st2.size() > 1) return res; if (st2.empty()) { res[0] = 1; return res; } int val = *st2.begin(); int prv = st.size(); st.insert(val); if (st.size() > prv) return res; res[0] = 1; return res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5720 KB | Output is correct |
2 | Incorrect | 1 ms | 5724 KB | 2nd lines differ - on the 4th token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5724 KB | Output is correct |
2 | Correct | 1 ms | 5724 KB | Output is correct |
3 | Correct | 1 ms | 5724 KB | Output is correct |
4 | Correct | 1 ms | 5724 KB | Output is correct |
5 | Correct | 1 ms | 5724 KB | Output is correct |
6 | Correct | 1 ms | 5724 KB | Output is correct |
7 | Correct | 1 ms | 5724 KB | Output is correct |
8 | Correct | 1 ms | 5724 KB | Output is correct |
9 | Correct | 1 ms | 5724 KB | Output is correct |
10 | Correct | 1 ms | 5724 KB | Output is correct |
11 | Correct | 1 ms | 5724 KB | Output is correct |
12 | Correct | 2 ms | 5724 KB | Output is correct |
13 | Correct | 1 ms | 5724 KB | Output is correct |
14 | Correct | 1 ms | 5724 KB | Output is correct |
15 | Correct | 1 ms | 5724 KB | Output is correct |
16 | Correct | 1 ms | 5724 KB | Output is correct |
17 | Correct | 1 ms | 5724 KB | Output is correct |
18 | Correct | 1 ms | 5724 KB | Output is correct |
19 | Correct | 1 ms | 5720 KB | Output is correct |
20 | Correct | 1 ms | 5724 KB | Output is correct |
21 | Correct | 1 ms | 5724 KB | Output is correct |
22 | Correct | 1 ms | 5724 KB | Output is correct |
23 | Correct | 1 ms | 5724 KB | Output is correct |
24 | Correct | 1 ms | 5724 KB | Output is correct |
25 | Correct | 2 ms | 5724 KB | Output is correct |
26 | Correct | 2 ms | 5724 KB | Output is correct |
27 | Correct | 1 ms | 5724 KB | Output is correct |
28 | Correct | 1 ms | 5724 KB | Output is correct |
29 | Correct | 1 ms | 5724 KB | Output is correct |
30 | Correct | 1 ms | 5724 KB | Output is correct |
31 | Correct | 1 ms | 5724 KB | Output is correct |
32 | Correct | 1 ms | 5724 KB | Output is correct |
33 | Correct | 1 ms | 5724 KB | Output is correct |
34 | Correct | 1 ms | 5724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5724 KB | Output is correct |
2 | Correct | 1 ms | 5724 KB | Output is correct |
3 | Correct | 1 ms | 5724 KB | Output is correct |
4 | Correct | 1 ms | 5724 KB | Output is correct |
5 | Correct | 1 ms | 5724 KB | Output is correct |
6 | Correct | 1 ms | 5724 KB | Output is correct |
7 | Incorrect | 82 ms | 19656 KB | 2nd lines differ - on the 2nd token, expected: '0', found: '1' |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5720 KB | Output is correct |
2 | Incorrect | 1 ms | 5724 KB | 2nd lines differ - on the 4th token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5724 KB | Output is correct |
2 | Correct | 1 ms | 5724 KB | Output is correct |
3 | Correct | 1 ms | 5724 KB | Output is correct |
4 | Correct | 1 ms | 5724 KB | Output is correct |
5 | Incorrect | 82 ms | 19656 KB | 2nd lines differ - on the 2nd token, expected: '0', found: '1' |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5720 KB | Output is correct |
2 | Incorrect | 1 ms | 5724 KB | 2nd lines differ - on the 4th token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5724 KB | Output is correct |
2 | Correct | 1 ms | 5724 KB | Output is correct |
3 | Correct | 1 ms | 5724 KB | Output is correct |
4 | Correct | 1 ms | 5724 KB | Output is correct |
5 | Correct | 1 ms | 5724 KB | Output is correct |
6 | Correct | 1 ms | 5724 KB | Output is correct |
7 | Correct | 1 ms | 5724 KB | Output is correct |
8 | Correct | 2 ms | 5724 KB | Output is correct |
9 | Correct | 1 ms | 5724 KB | Output is correct |
10 | Correct | 1 ms | 5724 KB | Output is correct |
11 | Correct | 1 ms | 5724 KB | Output is correct |
12 | Correct | 1 ms | 5724 KB | Output is correct |
13 | Correct | 1 ms | 5724 KB | Output is correct |
14 | Correct | 1 ms | 5724 KB | Output is correct |
15 | Correct | 1 ms | 5720 KB | Output is correct |
16 | Correct | 1 ms | 5724 KB | Output is correct |
17 | Correct | 1 ms | 5724 KB | Output is correct |
18 | Correct | 1 ms | 5724 KB | Output is correct |
19 | Correct | 1 ms | 5724 KB | Output is correct |
20 | Correct | 1 ms | 5724 KB | Output is correct |
21 | Correct | 2 ms | 5724 KB | Output is correct |
22 | Correct | 2 ms | 5724 KB | Output is correct |
23 | Correct | 1 ms | 5724 KB | Output is correct |
24 | Correct | 1 ms | 5724 KB | Output is correct |
25 | Correct | 2 ms | 5724 KB | Output is correct |
26 | Incorrect | 1 ms | 5724 KB | 2nd lines differ - on the 2nd token, expected: '0', found: '1' |
27 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5720 KB | Output is correct |
2 | Incorrect | 1 ms | 5724 KB | 2nd lines differ - on the 4th token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5724 KB | Output is correct |
2 | Correct | 1 ms | 5724 KB | Output is correct |
3 | Correct | 1 ms | 5724 KB | Output is correct |
4 | Correct | 1 ms | 5724 KB | Output is correct |
5 | Correct | 1 ms | 5724 KB | Output is correct |
6 | Correct | 1 ms | 5724 KB | Output is correct |
7 | Correct | 1 ms | 5724 KB | Output is correct |
8 | Correct | 2 ms | 5724 KB | Output is correct |
9 | Correct | 1 ms | 5724 KB | Output is correct |
10 | Correct | 1 ms | 5724 KB | Output is correct |
11 | Correct | 1 ms | 5724 KB | Output is correct |
12 | Correct | 1 ms | 5724 KB | Output is correct |
13 | Correct | 1 ms | 5724 KB | Output is correct |
14 | Correct | 1 ms | 5724 KB | Output is correct |
15 | Correct | 1 ms | 5720 KB | Output is correct |
16 | Correct | 1 ms | 5724 KB | Output is correct |
17 | Correct | 1 ms | 5724 KB | Output is correct |
18 | Correct | 1 ms | 5724 KB | Output is correct |
19 | Correct | 1 ms | 5724 KB | Output is correct |
20 | Correct | 1 ms | 5724 KB | Output is correct |
21 | Correct | 2 ms | 5724 KB | Output is correct |
22 | Correct | 2 ms | 5724 KB | Output is correct |
23 | Correct | 1 ms | 5724 KB | Output is correct |
24 | Correct | 1 ms | 5724 KB | Output is correct |
25 | Correct | 2 ms | 5724 KB | Output is correct |
26 | Incorrect | 1 ms | 5724 KB | 2nd lines differ - on the 2nd token, expected: '0', found: '1' |
27 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 5720 KB | Output is correct |
2 | Incorrect | 1 ms | 5724 KB | 2nd lines differ - on the 4th token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |