Submission #1066948

#TimeUsernameProblemLanguageResultExecution timeMemory
1066948pccBeech Tree (IOI23_beechtree)C++17
5 / 100
190 ms72364 KiB
#include "beechtree.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fs first #define sc second const int mxn = 2e5+10; vector<pii> tree[mxn]; pii par[mxn]; int dep[mxn]; vector<int> lvl[3]; set<int> st[mxn]; vector<int> ans; vector<int> col[mxn]; bitset<mxn> active; pii eul[mxn]; int ptr = 0; void dfs(int now){ eul[now].fs = ++ptr; for(auto [nxt,w]:tree[now]){ dfs(nxt); if(!ans[nxt])ans[now] = 0; if(st[now].size()<st[nxt].size())st[now].swap(st[nxt]); for(auto &i:st[nxt])st[now].insert(i); st[now].insert(w); } eul[now].sc = ptr; if(st[now].size() != tree[now].size())ans[now] = 0; int tar = -1; for(auto [nxt,w]:tree[now]){ if(col[w].size()<2)continue; int now = (col[w][0] == now?col[w][1]:col[w][0]); if(tar == -1)tar = now; else if(now != tar)ans[now] = 0; } return; } std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C){ ans = vector<int>(N,1); for(int i = 1;i<N;i++){ int p = P[i]; tree[p].push_back(pii(i,C[i])); par[i] = pii(p,C[i]); col[C[i]].push_back(p); } dfs(0); return ans; }

Compilation message (stderr)

beechtree.cpp: In function 'void dfs(int)':
beechtree.cpp:36:30: warning: 'now' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |   int now = (col[w][0] == now?col[w][1]:col[w][0]);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...