# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1047406 | 2024-08-07T12:39:22 Z | Abito | 참나무 (IOI23_beechtree) | C++17 | 2 ms | 8820 KB |
#include "beechtree.h" #include <bits/stdc++.h> #define pb push_back #define elif else if #define ep insert using namespace std; const int N=2e5+5; int a[N],c[N],p[N],n,mxd[N],dis[N]; vector<int> adj[N],s; void getmxd(int x){ if (x) dis[x]=dis[p[x]]+1; mxd[x]=dis[x]; for (auto u:adj[x]){ getmxd(u); mxd[x]=max(mxd[x],mxd[u]); }return; } void getsub(int x){ s.pb(x); for (auto u:adj[x]) getsub(u); return; } vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) { n=N; vector<int> ans(n,0); for (int i=0;i<n;i++) p[i]=P[i],c[i]=C[i]; for (int i=1;i<n;i++) adj[p[i]].pb(i); getmxd(0); for (int i=0;i<n;i++){ if (adj[i].empty()) ans[i]=1; elif (mxd[i]-dis[i]==1){ set<int> s; for (auto u:adj[i]) s.ep(c[u]); if (s.size()==adj[i].size()) ans[i]=1; } } for (int i=0;i<n;i++){ if (mxd[i]-dis[i]!=2) continue; getsub(i); set<int> par; for (int i=1;i<s.size();i++) par.ep(p[s[i]]); if (par.size()>2) continue; ans[i]=1; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8796 KB | Output is correct |
2 | Incorrect | 2 ms | 8796 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8796 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8796 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8796 KB | Output is correct |
2 | Correct | 1 ms | 8820 KB | Output is correct |
3 | Correct | 1 ms | 8796 KB | Output is correct |
4 | Correct | 1 ms | 8796 KB | Output is correct |
5 | Correct | 1 ms | 8796 KB | Output is correct |
6 | Correct | 1 ms | 8796 KB | Output is correct |
7 | Correct | 1 ms | 8796 KB | Output is correct |
8 | Correct | 2 ms | 8792 KB | Output is correct |
9 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '1', found: '0' |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8796 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8796 KB | Output is correct |
2 | Incorrect | 2 ms | 8796 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8796 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8796 KB | Output is correct |
2 | Incorrect | 2 ms | 8796 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8796 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8796 KB | Output is correct |
2 | Incorrect | 2 ms | 8796 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |