(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #547547

#TimeUsernameProblemLanguageResultExecution timeMemory
547547LucaDantasPacking Biscuits (IOI20_biscuits)C++17
100 / 100
62 ms1304 KiB
#include "biscuits.h" #include <cassert> #include <algorithm> #include <cstdio> #include <map> long long x; std::vector<long long> s; std::map<long long, long long> mp; long long g(long long n) { if(n <= 0) return 0; if(n == 1) return 1; if(mp.count(n)) return mp[n]; // retorno quantos caras menores que n são validos int i = 63-__builtin_clzll(n) - (__builtin_popcountll(n)==1); /* printf("%lld %d\n", n, i); fflush(stdout); */ // opção 1: não usar o i-ésimo bit long long ans = g(1ll<<i); // opção 2: usar o i-ésimo bit, porém tenho que garantir que a soma do valor é suficiente // aka as: s[i] >= y*x ==(estou usando o i-ésimo bit)=> s[i]/x > (y' + 1<<i) - 1 ==> s[i]/x + 1 - (1<<i) > y' ans += g(std::min(n, s[i]/x + 1) - (1ll << i)); mp[n] = ans; return ans; } long long count_tastiness(long long X, std::vector<long long> a) { mp.clear(); x = X; s = a; while(s.size() < 60) s.push_back(0); for(int i = 1; i < s.size(); i++) s[i] = (1ll << i) * s[i] + s[i-1]; return g(1ll<<60); }

Compilation message (stderr)

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