Submission #805950

#TimeUsernameProblemLanguageResultExecution timeMemory
805950PixelCatPacking Biscuits (IOI20_biscuits)C++14
9 / 100
1078 ms852 KiB
#include "biscuits.h" #ifdef NYAOWO #include "grader.cpp" #endif #include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define eb emplace_back #define int LL using namespace std; using i32 = int32_t; using LL = long long; using pii = pair<int, int>; const int MAXK = 60; int a[MAXK + 10]; int val[MAXK + 10]; int sum[MAXK + 10][MAXK + 10]; vector<pii> trans[MAXK + 10]; // {minimum #tokens, bit} int ans; // inline void dfs(int hibit, int cur, int k, int x) { // for(auto &i:trans[hibit]) { // if(i.F > cur) break; // cerr << "edge: " << hibit << " " << cur << " -> " << i.S + 1 << " " << cur - i.F << "\n"; // dfs(i.S + 1, cur - i.F, k, x); // } // ans++; // } inline void dfs2(int hibit, int cur, int x) { if(hibit < 0) { ans++; return; } cur = min(cur, sum[0][hibit]); dfs2(hibit - 1, cur, x); if(hibit >= 0 && cur / x >= (1ll << hibit)) { dfs2(hibit - 1, cur - (x << hibit), x); } } long long count_tastiness(long long x, std::vector<long long> _a) { int k = sz(_a); memset(a, 0, sizeof(a)); memset(val, 0, sizeof(val)); memset(sum, 0, sizeof(sum)); For(i, 0, MAXK) trans[i].clear(); For(i, 0, k - 1) { a[i] = _a[i]; val[i] = a[i] << i; } k = 60; For(i, 0, k) { sum[i][i] = val[i]; For(j, i + 1, k) sum[i][j] = sum[i][j - 1] + val[j]; } int lim = sum[0][k] / x; For(b1, 0, k - 1) { For(b2, b1, k - 1) { if(lim < (1ll << b2)) break; trans[b1].eb((x << b2) - sum[b1][b2], b2); } sort(all(trans[b1])); } ans = 0; // dfs(0, 0, k, x); // cerr << "\n"; dfs2(k, sum[0][k], x); return ans; }
#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...