이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <vector>
using namespace std;
vector<vector<int>> adj(100005);
vector<bool> vis(100005, 0);
vector<int> p(100005, 0);
int c = -1;
void dfs(int u)
{
if (vis[u])
return;
vis[u] = true;
c = max(c, p[u]);
for (auto i : adj[u])
dfs(i);
}
int solve(int n, int m, vector<int> f, vector<vector<int>> s)
{
for (int i = 1; i < n; i++)
adj[f[i]].push_back(i);
for (int j = 0; j < m; j++)
{
for (int i = 0; i < n - 1; i++)
p[s[j][i]] = max(p[s[j][i]], i);
}
int ans = 0;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < m; j++)
{
if (i > c && j == 0)
ans++;
dfs(s[j][i]);
}
}
c = -1;
return ans;
}
# | 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... |