Submission #802537

#TimeUsernameProblemLanguageResultExecution timeMemory
802537I_Love_EliskaM_Packing Biscuits (IOI20_biscuits)C++14
12 / 100
1080 ms1056 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define forn(i,n) for(int i=0;i<n;++i) #define pb push_back #define all(x) x.begin(), x.end() using ll = long long; #define pi pair<int,int> #define f first #define s second const int N=1e5+5; bitset<N> bs; ll p2(ll x, vector<ll> a) { while (a.size()<=60) a.pb(0); ll s=1; int k=0; while (k<60 && (a[k]==0 || s>=(1ll<<k))) { s+=(a[k]<<k); ++k; } ll old=s; ll s2=1; for (int t=k; t<60; ++t) { if (!a[t]) continue; if (s2 >= (1ll<<(t-k))) { s2+=(a[t]<<(t-k)); } else { s=s2*old; old=s; s2=1; k=t; --t; } } s=s2*old; old=s; s2=1; return s; } #define int ll ll f(ll x, vector<pi>&a, int i) { if (i>=a.size()-1) return 1+(a[i].f/x); if (a[i].f>=x) { a[i+1].f+=(a[i].f-x)>>(a[i+1].s-a[i].s); ll q1=f(x,a,i+1); a[i+1].f-=(a[i].f-x)>>(a[i+1].s-a[i].s); a[i+1].f+=(a[i].f)>>(a[i+1].s-a[i].s); ll q2=f(x,a,i+1); a[i+1].f-=(a[i].f)>>(a[i+1].s-a[i].s); return q1+q2; } else { a[i+1].f+=(a[i].f)>>(a[i+1].s-a[i].s); ll q=f(x,a,i+1); a[i+1].f-=(a[i].f)>>(a[i+1].s-a[i].s); return q; } } ll count_tastiness(ll x, vector<ll> a) { if (x==1) { return p2(x,a); } vector<pi> v; forn(i,a.size()) if (a[i]) v.pb({a[i],i}); return f(x,v,0); } #undef int

Compilation message (stderr)

biscuits.cpp: In function 'll first(ll, std::vector<std::pair<long long int, long long int> >&, ll)':
biscuits.cpp:45:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     if (i>=a.size()-1) return 1+(a[i].f/x);
      |         ~^~~~~~~~~~~~
biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:4:32: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forn(i,n) for(int i=0;i<n;++i)
......
   68 |     forn(i,a.size()) if (a[i]) v.pb({a[i],i});
      |          ~~~~~~~~~~             
biscuits.cpp:68:5: note: in expansion of macro 'forn'
   68 |     forn(i,a.size()) if (a[i]) v.pb({a[i],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...