Submission #1013876

#TimeUsernameProblemLanguageResultExecution timeMemory
1013876vjudge1Triumphal arch (POI13_luk)C++17
0 / 100
114 ms18576 KiB
// // main.cpp // IntensiveCamp 2 2024 // // Created by Ali AlSalman on 17/05/2024. // #include <bits/stdc++.h> #define endl '\n' using namespace std; struct segment_tree { private: int _offset; vector<int> _data; int _query(int u, int l, int r, int qlow, int qhi) { if (qlow <= l && r <= qhi) return _data[u]; else if (r <= qlow || qhi <= l) return 0; else { int m = (l + r) / 2; return _query(u * 2, l, m, qlow, qhi) * _query(u * 2 + 1, m, r, qlow, qhi); } } public: segment_tree(int n) { if (__builtin_popcount(n) == 1) _offset = n; else _offset = (1<<(32 - __builtin_clz(n))); _data.resize(_offset * 2); } segment_tree(vector<int>::iterator begin, vector<int>::iterator end) { } void inc(int i, int val = 1) { for (i += _offset; i; i /= 2) _data[i] += val; } void inc(pair<int, int> range) { auto &[l, r] = range; l += _offset; r += _offset; this->inc(l); this->inc(r, -1); } int query(int l, int r) { return _query(0, 0, _offset, l, r); } }; vector<int> depths; vector<vector<int>> children; void dfs(int u = 1, int p = -1, int d = 1) { depths[d]++; for (int child : children[u]) if (child != p) { dfs(child, u, d + 1); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin>>n; children.resize(n + 1); depths.resize(n + 1); for (int i = 1; i < n; i++) { int a, b; cin>>a>>b; children[a].push_back(b); children[b].push_back(a); } dfs(); int ans = 0; for (int i = 2; i < n + 1; i++) ans = max(ans, depths[i]); cout<<ans<<endl; }
#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...