| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1344088 | phamngocphuc2008 | 9월 (APIO24_september) | C++20 | 1 ms | 344 KiB |
#include "september.h"
#include <bits/stdc++.h>
using namespace std;
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
auto check = [&](const vector<int>& seq)
{
vector<bool> used(N);
used[0] = true;
for(int i = N-2; i >=0; --i)
{
int leaf = seq[i];
int par = F[leaf];
if(!used[par]) return false;
used[leaf] = true;
}
return true;
};
for(const auto &seq : S) if(!check(seq)) return -1;
vector<int> cnt(N);
int k = 0;
for(int i = 0; i + 1 < N; ++i)
{
for(int j = 0; j < M; ++j)
{
int leaf = S[j][i];
cnt[leaf]++;
}
bool ok = true;
for(int j = 0; j < N; ++j)
{
if(cnt[j] != 0 && cnt[j] != M)
{
ok = false;
break;
}
}
if(ok) ++k;
}
return k;
}
| # | 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... | ||||
