# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862910 | faustaadp | Beech Tree (IOI23_beechtree) | C++17 | 113 ms | 31540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "beechtree.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll NN = 2e5 + 5;
vector<pll> v[NN];
ll ada[NN], ade[NN];
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
vector<int> ret(N, 0);
for(ll i = 1; i < N; i++)
v[P[i]].pb(mp(i, C[i]));
ret[0] = 1;
{
vector<ll> tmp;
for(auto a : v[0])
{
ada[a.se] = 1;
tmp.pb(a.se);
}
sort(tmp.begin(), tmp.end());
for(ll j = 1; j < tmp.size(); j++)
if(tmp[j - 1] == tmp[j])
ret[0] = 0;
}
vector<pair<ll, vector<ll> > > vv;
for(ll i = 1; i < N; i++)
if(v[i].size() == 0)
ret[i] = 1;
else
{
ret[i] = 1;
vector<ll> tmp;
for(auto a : v[i])
tmp.pb(a.se);
sort(tmp.begin(), tmp.end());
for(ll j = 0; j < tmp.size(); j++)
{
if(!ada[tmp[j]])
ret[0] = 0;
}
for(ll j = 1; j < tmp.size(); j++)
if(tmp[j - 1] == tmp[j])
{
ret[0] = 0;
ret[i] = 0;
}
vv.pb(mp((ll)tmp.size(), tmp));
}
sort(vv.begin(), vv.end());
for(ll i = 1; i < vv.size(); i++)
{
for(auto a : vv[i].se)ade[a] = i;
for(auto a : vv[i - 1].se)
if(ade[a] != i)
ret[0] = 0;
}
return ret;
}
Compilation message (stderr)
# | 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... |