Submission #696466

#TimeUsernameProblemLanguageResultExecution timeMemory
696466Nhoksocqt1Burza (COCI16_burza)C++17
0 / 160
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define fi first #define se second typedef long long ll; typedef pair<int, int> ii; template<class X, class Y> inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);} template<class X, class Y> inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int Random(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); } int readInt() { bool minus = false; int result = 0; char ch; ch = getchar(); while(true) { if(ch == '-') break; if(ch >= '0' && ch <= '9') break; ch = getchar(); } if(ch == '-') minus = true; else result = ch - '0'; while(true) { ch = getchar(); if (ch < '0' || ch > '9') break; result = result * 10 + (ch - '0'); } if(minus) return -result; else return result; } const int MAXN = 402; vector<int> adj[MAXN]; int numNode, k; int solve(int u, int p = -1) { multiset<int> Set; for (int it = 0; it < int(adj[u].size()); ++it) { int v(adj[u][it]); if(v != p) Set.insert(solve(v, u)); } /*cout << u << ": "; for (int it : Set) cout << it << ' '; cout << '\n';*/ if(Set.size() <= 1) return 1; auto it = Set.end(); --it; --it; return 1 + *it; } void process() { cin >> numNode >> k; for (int i = 1; i < numNode; ++i) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } //cout << solve(1) << '\n'; if(solve(1) <= k) { cout << "DA"; } else { cout << "NE"; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("burza.inp", "r", stdin); // freopen("burza.out", "w", stdout); process(); return 0; }

Compilation message (stderr)

burza.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("O3")
      | 
burza.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("unroll-loops")
      |
#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...