제출 #1053499

#제출 시각아이디문제언어결과실행 시간메모리
1053499ProtonDecay314Packing Biscuits (IOI20_biscuits)C++17
44 / 100
1117 ms397132 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef vector<vpi> vvpi; typedef vector<vpll> vvpll; typedef vector<bool> vb; typedef vector<vb> vvb; typedef short int si; typedef vector<si> vsi; typedef vector<vsi> vvsi; #define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define L(varll, mn, mx) for(ll varll = (mn); varll < (mx); varll++) #define LR(varll, mx, mn) for(ll varll = (mx); varll > (mn); varll--) #define LI(vari, mn, mx) for(int vari = (mn); vari < (mx); vari++) #define LIR(vari, mx, mn) for(int vari = (mx); vari > (mn); vari--) #define INPV(varvec) for(auto& varveci : (varvec)) cin >> varveci #define fi first #define se second #define pb push_back #define INF(type) numeric_limits<type>::max() #define NINF(type) numeric_limits<type>::min() #define TCASES int t; cin >> t; while(t--) map<pll, ll> memo; set<pll> mem_comp; ll dp(ll y, ll i, const vll& sdx) { // cout << y << " " << i << "\n"; y = min(y, sdx[i] + 1ll); if(y <= 0ll) return 0ll; pll args = {y, i}; if(memo.count(args) == 0ll) { ll& ans = memo[args]; if(i == 0ll) { ans = min(y, sdx[0ll] + 1ll); } else { if(y <= (1ll << i)) { ans = dp(y, i - 1ll, sdx); } else { ans = dp(1ll << i, i, sdx) + dp(y - (1ll << i), i, sdx); } } } return memo[args]; } ll count_tastiness(ll x, vll a) { memo.clear(); // ! CLEAR YOUR MEMOIZATION STATE BEFORE PROCEEDING ll MAX_K = 61ll; ll k = a.size(); // for(ll i = 0ll; i < MAX_K - k; i++) { // a.pb(0ll); // } for(ll i = 0ll; i < k - 1ll; i++) { if(a[i] >= x + 2) { ll excess = a[i] - x; a[i + 1] += excess >> 1ll; a[i] -= (excess >> 1ll) << 1ll; } } vll sdx(k, 0ll); ll s = 0ll; L(i, 0ll, k) { s += a[i] << i; sdx[i] = s / x; } return dp(sdx[k - 1ll] + 1ll, k - 1ll, sdx); }

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

biscuits.cpp: In function 'll count_tastiness(ll, vll)':
biscuits.cpp:61:8: warning: unused variable 'MAX_K' [-Wunused-variable]
   61 |     ll MAX_K = 61ll;
      |        ^~~~~
#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...