(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #304831

#제출 시각아이디문제언어결과실행 시간메모리
3048312qbingxuan비스킷 담기 (IOI20_biscuits)C++14
100 / 100
347 ms1528 KiB
#include <bits/stdc++.h> #ifdef local #define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n" #define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__) template <typename H, typename ...T> void qqbx(const char*s, const H &h, T ...args) { for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s; std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n"); if constexpr (sizeof...(T)) qqbx(++s, args...); } #else #include "biscuits.h" #define debug(...) ((void)0) #define safe ((void)0) #endif // local #define pb emplace_back using namespace std; typedef long long ll; const int N = 2500025; ll count_tastiness(ll x, vector<ll> a) { int k = a.size(); cerr << x << '\n'; for(int i = 0; i < k; i++) cerr << a[i] << (i+1==k ? '\n' : ' '); vector<ll> sum(k); sum[0] = a[0]; for(int i = 1; i < k; i++) sum[i] = sum[i-1] + (a[i] << i); for(int i = 0; i < k; i++) sum[i] /= x; /* for(int i = 0; i < k; i++) sum[i] = min(sum[i], ((1LL<<i+1)-1)); */ #if 0 int ans = 0; for(int y = 0; y <= sum[k-1]; y++) { bool ok = 1; int yf = 0; for(int i = 0; i < k; i++) { yf += y & (1LL << i); if(yf > sum[i]) ok = 0; } if(ok) ++ans; } #else k = 60; sum.resize(k, sum.back()); vector<map<ll,ll>> mp(k); // count how many y, \forall i, (y & (11...11)) <= lim function<ll(int,ll)> calc = [&](int i, ll lim) -> ll { if(lim < 0) return 0; if(lim > sum[i]) lim = sum[i]; if(lim > ((1LL<<i+1)-1)) lim = ((1LL<<i+1)-1); if(i == 0) return lim + 1; if(mp[i].count(lim)) return mp[i][lim]; if(lim >= (1LL>>i)) return mp[i][lim] = calc(i-1, lim-(1LL<<i)) + calc(i-1, lim); return mp[i][lim] = calc(i-1, lim); }; ll ans = calc(k-1, sum[k-1]); #endif // 0 debug(ans); return ans; } #ifdef local signed main() { count_tastiness(3, {5, 2, 1}); count_tastiness(2, {2, 1, 2}); count_tastiness(1, {0, 2}); } #endif // local

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

biscuits.cpp: In lambda function:
biscuits.cpp:49:26: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   49 |         if(lim > ((1LL<<i+1)-1)) lim = ((1LL<<i+1)-1);
      |                         ~^~
biscuits.cpp:49:48: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   49 |         if(lim > ((1LL<<i+1)-1)) lim = ((1LL<<i+1)-1);
      |                                               ~^~
#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...