Submission #941251

#TimeUsernameProblemLanguageResultExecution timeMemory
941251WanWanBeech Tree (IOI23_beechtree)C++17
9 / 100
2031 ms11264 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=vector<int>(n,0); for(int i=1;i<n;i++){ childs[P[i]].push_back(i); } dfs(0,-1); for(int i=0;i<n;i++){ // check for this guy vector<int>vec; for(int x=0;x<n;x++){ if(child(i,x))vec.push_back(x); } debug(i,vec.size()); sort(vec.begin(),vec.end()); do { bool bad=0; unordered_map<int,int>cnt; for(int i=1;i<vec.size();i++){ int to=cnt[C[vec[i]]]; if(par[vec[i]] != vec[to]){ bad=1; } cnt[C[vec[i]]]++; } if(bad==0){ res[i]=1; } } while(next_permutation(vec.begin(),vec.end())); } return res; }

Compilation message (stderr)

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:51:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             for(int i=1;i<vec.size();i++){
      |                         ~^~~~~~~~~~~
#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...