# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1010363 | pcc | September (APIO24_september) | C++17 | 110 ms | 15428 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "september.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5+10;
int N,M;
vector<int> tree[mxn];
bitset<mxn> vis;
int cnt;
void init(){
for(int i = 0;i<N;i++){
vis[i] = false;
tree[i].clear();
}
cnt = 0;
}
void dfs(int now){
if(vis[now])return;
cnt += (vis[now] = 1);
for(auto nxt:tree[now]){
if(!vis[nxt])dfs(nxt);
}
return;
}
int solve(int NN, int MM, std::vector<int> F, std::vector<std::vector<int>> S) {
init();
N = NN;
M = MM;
for(int i = 1;i<N;i++)tree[F[i]].push_back(i);
int ans = 0;
for(int i = 0;i<S[0].size();i++){
for(int j = 0;j<M;j++)dfs(S[j][i]);
if(cnt == i+1)ans++;
}
return ans;
}
Compilation message (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... |