Submission #1086602

#TimeUsernameProblemLanguageResultExecution timeMemory
1086602chaoslongBurza (COCI16_burza)C++14
160 / 160
44 ms15064 KiB
// Calm down. // Think three times, code twice. #include "bits/stdc++.h" #define forr(_a,_b,_c) for(int _a = (_b); _a <= (_c); ++_a) #define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> (_c);) #define forf(_a,_b,_c) for(int _a = (_b); _a < (_c); ++_a) #define st first #define nd second #define ll long long #define ull unsigned long long #define pii pair <int,int> #define pll pair <ll,ll> #define piii pair <int,pii> #define vi vector <int> #define pb push_back #define mp make_pair #define all(x) begin(x),end(x) #define mask(i) (1LL << (i)) #define bit(x, i) (((x) >> (i)) & 1) #define bp __builtin_popcountll #define file "test" using namespace std; const int N = 2e5 + 5; const int mod = 1e9 + 7; // 998244353 const ll oo = 1e18; int n, k, mx_cover[N]; map<int, int> lost; vector<int> a[N], cut[N], depth[N]; vector<pii> intervals; void dfs(int u, int pre, int d) { depth[d].pb(u); if(d == k) { lost[u] = lost.size(); // cout << u << " " << last[u] << "\n"; cut[u] = {u}; return; } for(int v: a[u]) { if(v == pre) continue; dfs(v, u, d+1); // cout << u << " " << v << "\n"; cut[u].insert(cut[u].end(), cut[v].begin(), cut[v].end()); } } void to_nho_cau() { cin >> n >> k; if(k * k >= n) { cout << "DA\n"; return; } forr(i, 1, n-1) { int u, v; cin >> u >> v; a[u].pb(v); a[v].pb(u); } dfs(1, 0, 0); // forr(i, 1, n) { // cout << i << ": \n"; // for(int v: cut[i]) cout << v << " "; // cout << "\n"; // } forr(i, 1, n) { if(cut[i].empty()) { intervals.pb({-1, -1}); continue; } intervals.pb({lost[cut[i].front()] + 1, lost[cut[i].back()] + 1}); } mx_cover[0] = 0; forf(ss, 1, mask(k)) { forr(i, 0, k-1) { if(bit(ss, i)) { int prev = mx_cover[ss ^ mask(i)]; // cout << ss << " " << i << " " << prev << "\n"; for(int v: depth[i+1]) { if(intervals[v-1].st <= prev + 1) { // cout << ss << " " << i << " " << prev << " " << v << "\n"; mx_cover[ss] = max(mx_cover[ss], intervals[v-1].nd); } } } } if(mx_cover[ss] == lost.size()) { cout << "DA\n"; return; } } cout << "NE\n"; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); #ifdef LOCAL freopen(file".inp","r",stdin); freopen(file".out","w",stdout); #endif int t = 1; //cin >> t; while(t--) to_nho_cau(); } /* 1.self check: 2.long long 3.size of array 4.code for testing 5.initializing 6.modulo number */ /** ∧__∧ (`•ω• )づ__∧ (つ  /( •ω•。) しーJ (nnノ) pat pat **/ /** /\_/\ * (= ._.) * / >☕ \>💻 **/

Compilation message (stderr)

burza.cpp:119:9: warning: "/*" within comment [-Wcomment]
  119 | /**  /\_/\
      |          
burza.cpp: In function 'void to_nho_cau()':
burza.cpp:87:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<int, int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |         if(mx_cover[ss] == lost.size()) {
      |            ~~~~~~~~~~~~~^~~~~~~~~~~~~~
#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...