제출 #1055559

#제출 시각아이디문제언어결과실행 시간메모리
1055559Trent비스킷 담기 (IOI20_biscuits)C++17
0 / 100
3 ms2996 KiB
#include "biscuits.h" #include "bits/stdc++.h" using namespace std; #define forR(i, x) for(int i = 0; i < (x); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define all(x) x.begin(), x.end() typedef long long ll; typedef vector<ll> vll; ll INF = 1e18 + 10; ll mult(ll a, ll b) { return a > INF / b ? INF : a * b; } ll valOf(ll msk, vll& dc) { ll ret = 0; forR(i, dc.size()) if(msk & (1LL << i)) ret = min(INF, ret + dc[dc.size() - 1 - i]); return ret; } long long count_tastiness(long long x, std::vector<long long> a) { a.insert(a.begin(), (ll) 0); int k = 60; while(a.size() < k) a.push_back(0); vll ftp(k); vll sm(k); sm[0] = a[0]; REP(i, 1, k) sm[i] = sm[i-1] + (1LL << (i-1)) * a[i]; forR(i, k) { if(i == 0) ftp[i] = 1; else { cerr << i << ": \n"; ll st = sm[i]; vll dc = {mult(1LL << (i-1), x)}; ll msk = 0; for(int j = i-1; j >= 0; --j) { // st - dc(lo) >= sm[j], st - dc(hi) < sm[j] if(st - valOf(msk, dc) >= sm[j]) { ll lo=msk, hi=(1LL << dc.size()); while(hi - lo > 1) { int mid = (lo+hi)/2; if(st - valOf(mid, dc) >= sm[j]) lo = mid; else hi = mid; } ftp[i] += (hi - msk) * ftp[j]; cerr << j << ' ' << hi << ' ' << ftp[i] << '\n'; if(hi == (1LL << dc.size())) break; msk = hi << 1; dc.push_back((1LL << (j-1)) * x); } } } } vll vals = {sm[k-1]}; for(int i = k - 1; i > 0; --i) { vll nex; for(ll j : vals) { j = min(j, sm[i]); nex.push_back(j); if(j - mult(1LL << (i-1), x) >= 0) nex.push_back(j - (1LL << (i-1)) * x); } vals.swap(nex); } forR(i, k) cerr << sm[i] << ' '; cerr << '\n'; forR(i, k) cerr << ftp[i] << ' '; cerr << '\n'; assert(ftp[k-1] == vals.size()); return vals.size(); }

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

biscuits.cpp: In function 'll valOf(ll, vll&)':
biscuits.cpp:4:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forR(i, x) for(int i = 0; i < (x); ++i)
      |                                     ^
biscuits.cpp:16:5: note: in expansion of macro 'forR'
   16 |     forR(i, dc.size()) if(msk & (1LL << i)) ret = min(INF, ret + dc[dc.size() - 1 - i]);
      |     ^~~~
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:22:20: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while(a.size() < k) a.push_back(0);
      |           ~~~~~~~~~^~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from biscuits.cpp:2:
biscuits.cpp:69:21: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     assert(ftp[k-1] == vals.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...