Submission #546833

#TimeUsernameProblemLanguageResultExecution timeMemory
546833LucaDantasPacking Biscuits (IOI20_biscuits)C++17
21 / 100
1091 ms340 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; long long brute(long long x, std::vector<long long> a) { long long ans = 0; while(a.size() < 20) a.push_back(0); for(int mask = 0; mask <= 100000; mask++) { long long tem = 0; bool ok = 1; for(int b = 0; b < 20; b++) { tem += a[b]; if(mask&(1<<b)) { if(tem >= x) tem -= x; else {ok = 0; break;} } tem >>= 1; } ans += ok; } return ans; } long long x1(long long x, std::vector<long long> a) { while(a.size() < 128) a.push_back(0); int atv = 0; for(int i = 0; i+1 < a.size(); i++) { if(a[i]&1) a[i+1] += a[i]/2, a[i] = 1; else a[i+1] += max(0ll, a[i]/2-1), a[i] = min(a[i], 2ll); atv += a[i] > 0; } long long dp[2]{}, new_dp[2]{}; dp[0] = dp[1] = 1; for(int i = (int)(a.size()) - 1; i >= 0; i--) { if(!a[i]) { new_dp[0] = dp[0]; new_dp[1] = dp[0]; } else if(a[i] == 1) { new_dp[0] = 2*dp[0]; new_dp[1] = dp[1]; } else if(a[i] == 2) { new_dp[0] = 2*dp[0] + dp[1]; new_dp[1] = dp[1]; } dp[0] = new_dp[0]; dp[1] = new_dp[1]; } return dp[0]; } long long count_tastiness(long long x, std::vector<long long> a) { if(x == 1) return x1(x, a); // return -1; return brute(x, a); }

Compilation message (stderr)

biscuits.cpp: In function 'long long int x1(long long int, std::vector<long long int>)':
biscuits.cpp:29:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0; i+1 < a.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...