| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1334463 | x93bd0 | 9월 (APIO24_september) | C++20 | 2 ms | 580 KiB |
#include <bits/stdc++.h>
using namespace std;
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
vector<vector<int>> C(N);
for (uint x = 1; x < N; x++)
C[F[x]].push_back(x);
int CC[N];
for (uint x = 0; x < N; x++)
CC[x] = C[x].size();
set<uint> removed, toberemoved;
function<void(uint)> dfs = [&](uint n) {
for (uint c: C[n]) {
if (toberemoved.count(c) || removed.count(c)) continue;
toberemoved.insert(c);
dfs(c);
}
};
uint K = 0;
uint badfllstate = 0;
map<uint, uint> FLL;
for (uint i = 0; i < N - 1; i++) {
// printf("===\n");
// for (uint x: removed)
// printf("%d ", x);
// printf("\n");
// for (uint x: toberemoved)
// printf("%d ", x);
// printf("\n");
for (uint x = 0; x < M; x++) {
if (!FLL[S[x][i]]) {
badfllstate++;
uint n = S[x][i];
while (F[n] != -1) {
CC[F[n]]--;
if (toberemoved.count(n))
toberemoved.erase(n);
removed.insert(n);
if (!CC[F[n]])
n = F[n];
else
break;
}
dfs(S[x][i]);
}
FLL[S[x][i]]++;
if (FLL[S[x][i]] == M) badfllstate--;
}
if (!badfllstate && toberemoved.empty()) {
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... | ||||
