# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1039046 | fv3 | Beech Tree (IOI23_beechtree) | C++17 | 2083 ms | 26864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "beechtree.h"
using namespace std;
vector<int> b, p, c;
vector<vector<int>> adj;
void solve(int index)
{
vector<int> children;
queue<int> q;
q.push(index);
while (!q.empty())
{
int s = q.front();
q.pop();
for (auto node : adj[s])
{
children.push_back(node);
q.push(node);
}
}
sort(children.begin(), children.end());
map<int, int> cnt;
b[index] = 1;
do
{
map<int, int> label;
label[index] = 0;
for (int i = 0; i < children.size(); i++)
label[children[i]] = i+1;
bool ok = true;
for (auto child : children)
{
if (cnt[c[child]]++ != label[p[child]])
{
ok = false;
break;
}
}
if (ok)
return;
} while (next_permutation(children.begin(), children.end()));
b[index] = 0;
}
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C)
{
p = P; c = C;
b = vector<int>(N);
adj = vector<vector<int>>(N);
for (int i = 1; i < N; i++)
adj[P[i]].push_back(i);
for (int i = 0; i < N; i++)
{
solve(i);
}
return b;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |