| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1364818 | maharram234567 | 9월 (APIO24_september) | C++20 | 76 ms | 8272 KiB |
#include "september.h"
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> vis, pos;
vector<vector<int>> g;
int mx=0;
void dfs(int node) {
vis[node]=1;
if (pos[node]!=-1) {
mx=max(mx,pos[node]);
}
for(int i:g[node]) {
if(!vis[i]) {
dfs(i);
}
}
}
int solve(int n, int m, vector<int> par, vector<vector<int>> s) {
vis.assign(n, 0);
pos.assign(n, -1);
g.assign(n, vector<int>());
mx=0;
for(int i=1; i<n; i++) {
g[par[i]].pb(i);
}
for(int i=0; i<n-1; i++) {
pos[s[0][i]]=i;
}
int res=0, i=0;
while(i<n-1) {
while(i<n-1 && i<=mx) {
int node=s[0][i];
if(vis[node]==0) {
dfs(node);
}
i++;
}
res++;
if(i<n-1) mx=i;
}
return res;
}
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
