# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
773210 | cadmiumsky | 비스킷 담기 (IOI20_biscuits) | C++17 | 56 ms | 1392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using ld = long double;
#define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
const int nmax = 60 + 2;
int k = 0;
vector<ll> a;
vector<ll> nxt;
ll x;
unordered_map<ll, ll, custom_hash> dp[nmax];
ll bkt(int p, int accum) {
if(p > k && accum < x) return 1;
if(dp[p].count(accum)) return dp[p][accum];
return dp[p][accum] = bkt(p + 1, (a[p] + accum) / 2) + (a[p] + accum >= x? bkt(p + 1, (a[p] + accum - x) / 2) : 0);
}
ll basedkt(int p, int limit) {
if(p == -1) return 1;
limit = min({limit, (1LL << p + 1) - 1, a[p]});
if(dp[p].count(limit)) return dp[p][limit];
if((1LL << p) <= limit) dp[p][limit] += basedkt(p - 1, limit - (1LL << p));
dp[p][limit] += basedkt(p - 1, limit);
return dp[p][limit];
}
long long count_tastiness(long long XXX, std::vector<long long> AAA) {
x = XXX;
a = AAA;
k = sz(a);
while(sz(a) < nmax) a.emplace_back(0);
int prv = nmax;
nxt.resize(nmax);
auto tmp = a;
for(int i = 0; i < sz(a); i++) {
a[i] *= (1LL << i);
}
for(int i = 1; i < sz(a); i++) a[i] += a[i - 1];
for(auto &b : a) b /= x;
for(int i = 0; i < nmax; i++) dp[i].clear();
int val = a.back();
return basedkt(sz(a) - 1, a.back());
}
#undef int
/**
Anul asta se da centroid.
-- Surse oficiale
*/
컴파일 시 표준 에러 (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... |