# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
847680 | 2023-09-10T06:44:47 Z | vjudge1 | 참나무 (IOI23_beechtree) | C++17 | 1 ms | 348 KB |
#include "beechtree.h" #include <bits/stdc++.h> using namespace std; std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C) { vector<vector<int>> adj(N); for (int i = 1; i < N; i++) { adj[P[i]].emplace_back(i); } vector<vector<int>> c(N); for (int i = 1; i < N; i++) { c[P[i]].emplace_back(C[i] - 1); } vector<int> f(N, 0); vector<int> d(N); function<void(int)> dfs = [&](int u) { int cnt = 0; for (int v : adj[u]) { dfs(v); d[u] = max(d[v] + 1, d[u]); cnt += adj[v].size() != 0; } if (d[u] > 2) return void(f[u] = 0); if (d[u] < 2) return void(f[u] = 1); if (cnt == 0) f[u] = 1; if (cnt == 1) { f[u] = 1; vector<int> ord(1, u); for (int v : adj[u]) ord.emplace_back(v); sort(ord.begin(), ord.end(), [&](int i, int j) { return c[i].size() > c[j].size(); }); if (ord[0] != u) return void(f[u] = 0); for (int i = 1; i < N; i++) { for (int j : c[ord[i]]) { if (!binary_search(c[ord[i - 1]].begin(), c[ord[i - 1]].end(), j)) return void(f[u] = 0); } } } if (cnt > 1) f[u] = 0; }; dfs(0); for (int i = 0; i < N; i++) { sort(c[i].begin(), c[i].end()); for (int j = 1; j < c[i].size(); j++) { if (c[i][j] == c[i][j - 1]) f[i] = 0; } } return f; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
9 | Incorrect | 1 ms | 344 KB | 2nd lines differ - on the 1st token, expected: '1', found: '0' |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |