Submission #1098792

#TimeUsernameProblemLanguageResultExecution timeMemory
1098792IcelastBurza (COCI16_burza)C++17
0 / 160
1 ms348 KiB
#include <iostream> #include <bits/stdc++.h> #define ll long long using namespace std; const ll maxn = 2*1e5+5, INF = 1e9+9; void solve(){ int n, k; cin >> n >> k; vector<vector<int>> adj(n+1); for(int i = 1; i < n; i++){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } vector<ll> f(n+1); auto dfs = [&](auto dfs, int u, int p, int len) -> void{ vector<ll> a; if(len == k){ f[u] = INF; return; } ll sum = 0; for(int v : adj[u]){ if(v == p) continue; dfs(dfs, v, u, len+1); a.push_back(f[v]); sum += f[v]; } sort(a.begin(), a.end(), greater<ll>()); f[u] = INF; for(int i = 0; i < a.size(); i++){ f[u] = min(f[u], sum-a[i]+i); sum-=a[i]; } if(a.empty()) f[u] = 0; }; dfs(dfs, 1, 0, 0); ll ans = f[1]; if(ans == 0){ cout << "DA"; }else{ cout << "NE"; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }

Compilation message (stderr)

burza.cpp: In lambda function:
burza.cpp:33:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i = 0; i < a.size(); i++){
      |                        ~~^~~~~~~~~~
burza.cpp: In instantiation of 'solve()::<lambda(auto:23, int, int, int)> [with auto:23 = solve()::<lambda(auto:23, int, int, int)>]':
burza.cpp:39:21:   required from here
burza.cpp:33:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
#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...