# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1047416 | 2024-08-07T12:42:37 Z | Abito | Beech Tree (IOI23_beechtree) | C++17 | 2 ms | 8796 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++){ s.clear(); if (mxd[i]-dis[i]!=2) continue; getsub(i); set<int> par; bool ok=true; for (int i=1;i<s.size();i++) par.ep(p[s[i]]),ok&=ans[s[i]]; if (par.size()>2 || ok) continue; ans[i]=1; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8792 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8796 KB | Output is correct |
2 | Correct | 2 ms | 8796 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 | 1 ms | 8796 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 | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8792 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8792 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 8792 KB | Output is correct |
2 | Incorrect | 1 ms | 8796 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |