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 <bits/stdc++.h>
#include "september.h"
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
const int N = 1e5 + 7;
int bio[N];
vector <int> adj[N];
int dfs(int x) {
bio[x] = 1;
int cnt = 1;
for (int y : adj[x]) if (!bio[y]) cnt += dfs(y);
return cnt;
}
int solve(int n, int m, vector <int> p, vector <vector <int> > a) {
for (int i = 0; i < n; i++) {
bio[i] = 0;
adj[i].clear();
}
for (int i = 1; i < n; i++) adj[p[i]].pb(i);
int cnt = 0, x = 0, rem = 0;
while (x < n-1) {
cnt++;
do {
for (int i = 0; i < m; i++) {
if (bio[a[i][x]]) rem--;
else rem += m*dfs(a[i][x])-1;
}
x++;
} while (rem);
}
return cnt;
}
# | 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... |