| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1362565 | opeleklanos | September (APIO24_september) | C++20 | 213 ms | 17208 KiB |
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#include "september.h"
vector<vector<int>> adj;
vector<set<int>> needToFind;
vector<vector<int>> vis;
void dfs(int st, int x){
vis[x][st] = 1;
for(auto i : adj[st]){
if(vis[x][i]) continue;
needToFind[x].insert(i);
dfs(i, x);
}
}
int solve(int N, int M, vector<int> F, vector<vector<int>> S){
needToFind.assign(M, {});
adj.assign(N, {});
for(int i = 1; i<N; i++) adj[F[i]].push_back(i);
vis.assign(M, vector<int>(N, 0));
set<int> sel;
int ans = 0;
for(int i = 0; i<N-1; i++){
for(int j = 0; j<M; j++) sel.insert(S[j][i]);
int addans = 1;
for(int j = 0; j<M; j++){
needToFind[j].erase(S[j][i]);
dfs(S[j][i], j);
if(needToFind[j].size() != 0) addans=0;
}
if(sel.size() == i+1){
ans += addans;
}
}
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... | ||||
