Submission #941252

#TimeUsernameProblemLanguageResultExecution timeMemory
941252WanWanBeech Tree (IOI23_beechtree)C++17
5 / 100
59 ms6996 KiB
#include "beechtree.h" #include <bits/stdc++.h> using namespace std; #ifdef LOCAL void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) #else #define debug(...) #endif const int MAXN = 2005; const int inf=1000000500ll; const long long oo =1000000000000000500ll; const int MOD = (int)1e9+7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef pair<int,int> pi; int par[MAXN]; vector<int>childs[MAXN]; int st[MAXN],en[MAXN]; int TIME; bool child(int par, int child){ if(st[par]<=st[child] && en[par]>=en[child])return 1; return 0; } void dfs(int x, int p){ st[x]=TIME++; par[x]=p; for(auto v:childs[x]){ dfs(v,x); } en[x]=TIME-1; } std::vector<int> beechtree(int n, int M, std::vector<int> P, std::vector<int> C) { vector<int>res(n,0); int lst=n; set<int>s; for(int i=n-1;i>=0;i--){ if(i) s.insert(C[i]); if(s.size() == 1)lst=i; else break; } for(int i=0;i<n;i++){ if(i<lst-1)res[i]=0; else res[i]=1; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...