Submission #425635

#TimeUsernameProblemLanguageResultExecution timeMemory
425635idk321Packing Biscuits (IOI20_biscuits)C++17
9 / 100
224 ms332 KiB
#include "biscuits.h" #include <bits/stdc++.h>; using namespace std; typedef long long ll; long long count_tastiness(long long x, std::vector<long long> a) { ll sum = 0; int k = 60; for (int i = 0; i < a.size(); i++) { sum += (1LL << i) * a[i]; } if (sum <= 100000) { int res = 0; for (int i = 0; i <= sum; i++) { bool poss = true; vector<ll> cur(60); for (int j = 0; j < a.size(); j++) cur[j] = a[j]; for (int j = 0; j < k; j++) { if ((1LL << j) & i) { cur[j] -= x; if (cur[j] < 0) { poss = false; break; } } if (j + 1 < k) { cur[j + 1] += cur[j] / 2; } } if (poss) res++; } return res; } if (x == 1) { vector<ll> cur(k); for (int j = 0; j < a.size(); j++) cur[j] = a[j]; int prev = -1; vector<vector<int>> ivals; for (int i = 0; i < k; i++) { if (cur[i] == 0 && prev != -1) { vector<int> ival; for (int j = prev; j <= i - 1; j++) ival.push_back(cur[j]); ivals.push_back(ival); prev = -1; } if (cur[i] != 0 && prev == -1) { prev = i; } } if (prev != -1) { vector<int> ival; for (int j = prev; j < k; j++) ival.push_back(cur[j]); ivals.push_back(ival); prev = -1; } ll res = 1; for (auto ival : ivals) { ll csum = 1; for (int i = 0; i < ival.size(); i++) { csum += (1LL << i) * ival[i]; } res *= csum; } return res; } return 0; } /* 1 15 1 1 2 0 2 1 0 0 2 2 1 1 2 0 0 1 */

Compilation message (stderr)

biscuits.cpp:2:25: warning: extra tokens at end of #include directive
    2 | #include <bits/stdc++.h>;
      |                         ^
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
biscuits.cpp:26:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             for (int j = 0; j < a.size(); j++) cur[j] = a[j];
      |                             ~~^~~~~~~~~~
biscuits.cpp:57:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for (int j = 0; j < a.size(); j++) cur[j] = a[j];
      |                         ~~^~~~~~~~~~
biscuits.cpp:90:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |             for (int i = 0; i < ival.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...