이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |