# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433110 | peuch | Packing Biscuits (IOI20_biscuits) | C++17 | 1099 ms | 63216 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
vector<map<long long, long long> > dp;
vector<long long> v(60);
long long X;
long long getDP(int bit, long long cnt){
cnt += v[bit];
if(bit == 60) return 1;
if(dp[bit][cnt] != 0) return dp[bit][cnt];
dp[bit][cnt] = getDP(bit + 1, cnt / 2);
if(cnt >= X) dp[bit][cnt] += getDP(bit + 1, (cnt - X) / 2);
return dp[bit][cnt];
}
long long sub1(long long x, vector<long long> a){
long long ini = 0;
long long ans = 1;
for(ini = 0; ini < 60;){
long long fim = ini;
long long sobra = 0;
long long num = 0;
long long cnt = 0;
while(fim < 60){
long long val = 0;
if(fim < a.size()) val = a[fim];
long long tot = val + sobra;
sobra = tot / 2;
if(tot % 2 == 1) num |= (1LL << cnt);
fim++;
cnt++;
if(sobra == 0) break;
}
ans *= num + 1;
ini = fim;
}
return ans;
}
long long count_tastiness(long long x, vector<long long> a) {
if(x == 1) return sub1(x, a);
X = x;
v = vector<long long> (60, 0);
dp = vector<map<long long, long long> > (60);
for(int i = 0; i < a.size(); i++)
v[i] = a[i];
return getDP(0, 0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |