Submission #877669

#TimeUsernameProblemLanguageResultExecution timeMemory
877669abczzPacking Biscuits (IOI20_biscuits)C++14
100 / 100
50 ms1892 KiB
#include "biscuits.h" #include <iostream> #include <vector> #define ll long long #define ull __int128 using namespace std; ll dp[121][121][2], f; long long count_tastiness(long long x, std::vector<long long> a) { vector <ull> V; ull z = x, s = 1, y = 1; f = 0; for (auto u : a) V.push_back(u); while (V.size() < 120) V.push_back(0); for (int i=0; i<V.size(); ++i) { s *= 2; for (int j=0; j<i; ++j) { V[i] *= 2; } if (i) V[i] += V[i-1]; } for (int i=0; i<V.size(); ++i) { for (int j=0; j<V.size(); ++j) { dp[i][j][0] = dp[i][j][1] = 0; } } for (int i=0; i<V.size(); ++i) { y *= 2; V[i] /= z; V[i] = min(V[i], y-1); //cout << (ll)V[i] << " "; } //cout << endl; y /= 2; if ((V.back() & y)) ++dp[V.size()-1][V.size()-1][0]; ++dp[V.size()-1][V.size()-1][1]; for (int i=V.size()-1; i>0; --i) { y /= 2; s /= 2; for (int j=i; j<V.size(); ++j) { //cout << i << " " << j << " " << dp[i][j][0] << endl; //cout << i << " " << j << " " << dp[i][j][1] << endl; if ((V[i-1] & y)) dp[i-1][i-1][0] += dp[i][j][0]; dp[i-1][i-1][1] += dp[i][j][0]; if ((V[j] & (s-1)) <= (V[i-1] & (s-1))) { if ((V[j] & y)) dp[i-1][j][0] += dp[i][j][1]; dp[i-1][j][1] += dp[i][j][1]; } else { if ((V[i-1] & y)) dp[i-1][i-1][0] += dp[i][j][1]; dp[i-1][i-1][1] += dp[i][j][1]; } } } for (int i=0; i<V.size(); ++i) { f += dp[0][i][0] + dp[0][i][1]; } return f; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:17:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i=0; i<V.size(); ++i) {
      |                ~^~~~~~~~~
biscuits.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (int i=0; i<V.size(); ++i) {
      |                ~^~~~~~~~~
biscuits.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for (int j=0; j<V.size(); ++j) {
      |                 ~^~~~~~~~~
biscuits.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for (int i=0; i<V.size(); ++i) {
      |                ~^~~~~~~~~
biscuits.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (int j=i; j<V.size(); ++j) {
      |                 ~^~~~~~~~~
biscuits.cpp:57:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for (int i=0; i<V.size(); ++i) {
      |                ~^~~~~~~~~
#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...