# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
997420 | 2024-06-12T09:38:52 Z | Trisanu_Das | 9월 (APIO24_september) | C++17 | 134 ms | 37736 KB |
#include "september.h" #include <bits/stdc++.h> #define INF 1e18 using namespace std; typedef long long ll; vector<int> adj[800005]; int dp[800005]; void dfs(int s, int e) { for (auto u : adj[s]) { if (u == e) continue; dfs(u, s); dp[s] = max(dp[s], dp[u]); } } int solve(int N, int M, vector<int> F, vector<vector<int>> S) { for (int i = 0; i < N; i++) { adj[i].clear(); dp[i] = 0; } for (int i = 1; i < N; i++) { adj[i].push_back(F[i]); adj[F[i]].push_back(i); } for (int i = 0; i < S[0].size(); i++) dp[S[0][i]] = i; dfs(0, -1); int ans = 0, i = 0; while (i < S[0].size()) { int j = dp[S[0][i]]; int maxn = dp[S[0][i]]; int k = i; while (k <= maxn) { maxn = max(maxn, dp[S[0][k]]); ++k; } ++ans; i = maxn + 1; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 20056 KB | Output is correct |
2 | Correct | 3 ms | 20060 KB | Output is correct |
3 | Correct | 3 ms | 20060 KB | Output is correct |
4 | Correct | 4 ms | 20060 KB | Output is correct |
5 | Correct | 3 ms | 20060 KB | Output is correct |
6 | Correct | 3 ms | 20060 KB | Output is correct |
7 | Correct | 3 ms | 20060 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 20056 KB | Output is correct |
2 | Correct | 3 ms | 20060 KB | Output is correct |
3 | Correct | 3 ms | 20060 KB | Output is correct |
4 | Correct | 4 ms | 20060 KB | Output is correct |
5 | Correct | 3 ms | 20060 KB | Output is correct |
6 | Correct | 3 ms | 20060 KB | Output is correct |
7 | Correct | 3 ms | 20060 KB | Output is correct |
8 | Incorrect | 4 ms | 20060 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 20056 KB | Output is correct |
2 | Correct | 4 ms | 20060 KB | Output is correct |
3 | Correct | 4 ms | 20060 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 20056 KB | Output is correct |
2 | Correct | 3 ms | 20060 KB | Output is correct |
3 | Correct | 3 ms | 20060 KB | Output is correct |
4 | Correct | 4 ms | 20060 KB | Output is correct |
5 | Correct | 3 ms | 20060 KB | Output is correct |
6 | Correct | 3 ms | 20060 KB | Output is correct |
7 | Correct | 3 ms | 20060 KB | Output is correct |
8 | Correct | 4 ms | 20056 KB | Output is correct |
9 | Correct | 4 ms | 20060 KB | Output is correct |
10 | Correct | 4 ms | 20060 KB | Output is correct |
11 | Correct | 4 ms | 20060 KB | Output is correct |
12 | Correct | 4 ms | 20060 KB | Output is correct |
13 | Correct | 4 ms | 20060 KB | Output is correct |
14 | Correct | 5 ms | 20060 KB | Output is correct |
15 | Correct | 4 ms | 20060 KB | Output is correct |
16 | Correct | 3 ms | 20060 KB | Output is correct |
17 | Correct | 4 ms | 20056 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 20056 KB | Output is correct |
2 | Correct | 4 ms | 20060 KB | Output is correct |
3 | Correct | 4 ms | 20060 KB | Output is correct |
4 | Incorrect | 4 ms | 20316 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 20056 KB | Output is correct |
2 | Correct | 3 ms | 20060 KB | Output is correct |
3 | Correct | 3 ms | 20060 KB | Output is correct |
4 | Correct | 4 ms | 20060 KB | Output is correct |
5 | Correct | 3 ms | 20060 KB | Output is correct |
6 | Correct | 3 ms | 20060 KB | Output is correct |
7 | Correct | 3 ms | 20060 KB | Output is correct |
8 | Incorrect | 4 ms | 20060 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 20056 KB | Output is correct |
2 | Correct | 4 ms | 20060 KB | Output is correct |
3 | Correct | 4 ms | 20060 KB | Output is correct |
4 | Correct | 112 ms | 36412 KB | Output is correct |
5 | Correct | 113 ms | 37736 KB | Output is correct |
6 | Correct | 108 ms | 37724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 20056 KB | Output is correct |
2 | Correct | 3 ms | 20060 KB | Output is correct |
3 | Correct | 3 ms | 20060 KB | Output is correct |
4 | Correct | 4 ms | 20060 KB | Output is correct |
5 | Correct | 3 ms | 20060 KB | Output is correct |
6 | Correct | 3 ms | 20060 KB | Output is correct |
7 | Correct | 3 ms | 20060 KB | Output is correct |
8 | Correct | 4 ms | 20056 KB | Output is correct |
9 | Correct | 4 ms | 20060 KB | Output is correct |
10 | Correct | 4 ms | 20060 KB | Output is correct |
11 | Correct | 4 ms | 20060 KB | Output is correct |
12 | Correct | 4 ms | 20060 KB | Output is correct |
13 | Correct | 4 ms | 20060 KB | Output is correct |
14 | Correct | 5 ms | 20060 KB | Output is correct |
15 | Correct | 4 ms | 20060 KB | Output is correct |
16 | Correct | 3 ms | 20060 KB | Output is correct |
17 | Correct | 4 ms | 20056 KB | Output is correct |
18 | Correct | 112 ms | 36412 KB | Output is correct |
19 | Correct | 113 ms | 37736 KB | Output is correct |
20 | Correct | 108 ms | 37724 KB | Output is correct |
21 | Correct | 120 ms | 30892 KB | Output is correct |
22 | Correct | 120 ms | 30008 KB | Output is correct |
23 | Correct | 111 ms | 31608 KB | Output is correct |
24 | Correct | 134 ms | 31664 KB | Output is correct |
25 | Correct | 116 ms | 31148 KB | Output is correct |
26 | Correct | 122 ms | 30896 KB | Output is correct |
27 | Correct | 105 ms | 29336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 20056 KB | Output is correct |
2 | Correct | 4 ms | 20060 KB | Output is correct |
3 | Correct | 4 ms | 20060 KB | Output is correct |
4 | Incorrect | 4 ms | 20316 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 20056 KB | Output is correct |
2 | Correct | 3 ms | 20060 KB | Output is correct |
3 | Correct | 3 ms | 20060 KB | Output is correct |
4 | Correct | 4 ms | 20060 KB | Output is correct |
5 | Correct | 3 ms | 20060 KB | Output is correct |
6 | Correct | 3 ms | 20060 KB | Output is correct |
7 | Correct | 3 ms | 20060 KB | Output is correct |
8 | Incorrect | 4 ms | 20060 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |