| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1355938 | orgiloogii | September (APIO24_september) | C++20 | 86 ms | 17148 KiB |
#include "september.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> mx;
vector <vector <int>> adj;
void dfs(int u, int p) {
for (auto v : adj[u]) {
if (v == p) continue;
dfs(v, u);
mx[u] = max(mx[u], mx[v]);
}
}
int solve(int n, int m, vector<int> f, vector<vector<int>> s) {
mx.assign(n + 1, 0);
adj.assign(n + 1, {});
for (int i = 0;i < m;i++) {
for (int j = 0;j < n - 1;j++) {
mx[s[i][j]] = max(mx[s[i][j]], j);
}
}
for (int i = 1;i < n;i++) {
adj[i].push_back(f[i]);
adj[f[i]].push_back(i);
}
dfs(0, -1);
int cnt[n + 1] = {0};
int freq[m + 1] = {0};
freq[0] = n;
int mxs = 0;
int ans = 0;
for (int i = 0;i < n - 1;i++) {
for (int j = 0;j < m;j++) {
freq[cnt[s[j][i]]]--;
cnt[s[j][i]]++;
freq[cnt[s[j][i]]]++;
mxs = max(mxs, mx[s[j][i]]);
}
if (freq[m] == i + 1 && mxs <= i) ans++;
}
return ans;
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
