제출 #1117374

#제출 시각아이디문제언어결과실행 시간메모리
1117374vux2codeBurza (COCI16_burza)C++17
160 / 160
40 ms3336 KiB
// Src : Vux2Code /* Note : */ #include <bits/stdc++.h> #define fi first #define se second using namespace std; // template <typename T> void vout(T s){ cout << s << endl; exit(0);} typedef int ll; typedef long double ld; typedef pair <ll, ll> pll; const ll maxN = 4e2 + 5, maxLog = 20; void maximize (ll &x, ll y) {x = max (x, y);} void minimize (ll &x, ll y) {x = min (x, y);} /* ---------HASHING-------- */ // const base = 31, mod2 = 1e9 + 9; /* ---------BITMASK-------- */ // ll count (ll x) {return __builtin_popcountll (x);} // ll fst (ll x) {return 63 - __builtin_clzll (x);} // ll last (ll x) {return __builtin_ctzll (x);} bool bit (ll x, ll y) {return ((x >> y) & 1);} ll t = 1; ll n, k, h [maxN], st [maxN], en [maxN], cnt; vector <ll> ke [maxN], hvec [maxN]; bool f [maxN] [1 << maxLog]; void dfs (ll x, ll pr) { if (x) h [x] = h [pr] + 1; if (h [x] == k - 1) { st [x] = cnt ++; en [x] = cnt; return; } st [x] = cnt; for (ll i : ke [x]) if (i != pr) { dfs (i, x); } en [x] = cnt; } bool solve () { cin >> n >> k; if (k * k >= n) return true; for (int i = 1, u, v; i < n; i ++) { cin >> u >> v; u --; v --; ke [u]. push_back (v); ke [v]. push_back (u); } h [0] = -1; dfs (0, -1); for (int i = 1; i < n; i ++) hvec [st [i]]. push_back (i); f [0] [0] = 1; for (int i = 0; i < cnt; i ++) { for (int mask = 0; mask < (1 << k); mask ++) { if (!f [i] [mask]) continue; for (ll j : hvec [i]) { if (bit (mask, h [j])) continue; f [en [j]] [mask | 1 << h [j]] = 1; } } } for (int i = 0; i < (1 << k); i ++) if (f [cnt] [i]) return true; return false; } int main () { ios::sync_with_stdio (0); cin. tie (0); cout. tie (0); #define TASK "task" if (fopen (TASK".inp", "r")) { freopen (TASK".inp", "r", stdin); freopen (TASK".out", "w", stdout); } // cin >> t; while (t --) cout << (solve () ? "DA" : "NE"); }

컴파일 시 표준 에러 (stderr) 메시지

burza.cpp: In function 'int main()':
burza.cpp:84:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         freopen (TASK".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
burza.cpp:85:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen (TASK".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...