(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 #415581

#TimeUsernameProblemLanguageResultExecution timeMemory
415581MKopchevPacking Biscuits (IOI20_biscuits)C++14
100 / 100
584 ms1292 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; const int nmax=64; long long inp[nmax],mem_x; bool eq(long long p,long long q,int bit) { //return p==q; long long coeff=1; while(bit<60) { p=p+inp[bit]*coeff; q=q+inp[bit]*coeff; if(min(2*coeff-1,p/mem_x)!=min(2*coeff-1,q/mem_x))return 0; bit++; coeff=coeff*2; } //if(p!=q)cout<<"gaz"<<endl; return 1; } long long rec(int SZ) { vector< pair<long long/*high*/,long long/*dp*/> > seen={},help; seen.push_back({0,1}); for(int bit=0;bit<SZ;bit++) { help={}; for(auto w:seen) { long long high=w.first+inp[bit]; help.push_back({high/2,w.second}); if(high>=mem_x)help.push_back({(high-mem_x)/2,w.second}); } sort(help.begin(),help.end()); seen={}; for(auto w:help) { if(seen.size()==0)seen.push_back(w); else if(eq(seen.back().first,w.first,bit+1))seen[seen.size()-1].second+=w.second; else seen.push_back(w); } //cout<<bit<<" -> "<<seen.size()<<endl; } //cout<<"seen: ";for(auto w:seen)cout<<w.first<<" with "<<w.second<<" , ";cout<<endl; long long ret=0; for(auto w:seen) ret+=(w.first/mem_x+1)*w.second; return ret; } long long count_tastiness(long long x, std::vector<long long> a) { while(a.size()>1&&a.back()==0)a.pop_back(); mem_x=x; for(int i=0;i<60;i++) { inp[i]=0; } for(int i=0;i<a.size();i++)inp[i]=a[i]; long long ret=rec(a.size()); return ret; } /* int main() { int q; assert(scanf("%d", &q) == 1); vector<int> k(q); vector<long long> x(q); vector<vector<long long>> a(q); vector<long long> results(q); for (int t = 0; t < q; t++) { assert(scanf("%d%lld", &k[t], &x[t]) == 2); a[t] = vector<long long>(k[t]); for (int i = 0; i < k[t]; i++) { assert(scanf("%lld", &a[t][i]) == 1); } } fclose(stdin); for (int t = 0; t < q; t++) { results[t] = count_tastiness(x[t], a[t]); } for (int t = 0; t < q; t++) { printf("%lld\n", results[t]); } fclose(stdout); return 0; } */

Compilation message (stderr)

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