Submission #780878

#TimeUsernameProblemLanguageResultExecution timeMemory
780878JosiaPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1 ms596 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define int long long long long count_tastiness(long long x, std::vector<long long> a) { assert(x==1); vector<int> b(100, 0); int carry = 0; for (int i = 0; i<b.size(); i++) { carry /= 2; int here = carry+(i<a.size()?a[i]:0); if (here == 0) continue; if (here%2==0) { b[i] = 2; carry = here - 2; } else { b[i] = 1; carry = here - 1; } } int res = 1; bool cont = 1; int lastCont = 0; int addup = 0; for (int i=0; i<62; i++) { if (!b[i]) { // lastCont = 0; res += addup; addup = 0; continue; } res *= 2; if (b[i] == 2) addup += 1<<lastCont; lastCont ++; } res += addup; return res; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:15:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for (int i = 0; i<b.size(); i++) {
      |                  ~^~~~~~~~~
biscuits.cpp:18:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   int here = carry+(i<a.size()?a[i]:0);
      |                     ~^~~~~~~~~
biscuits.cpp:33:7: warning: unused variable 'cont' [-Wunused-variable]
   33 |  bool cont = 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...