Submission #356843

#TimeUsernameProblemLanguageResultExecution timeMemory
356843KerimPacking Biscuits (IOI20_biscuits)C++17
100 / 100
867 ms1388 KiB
#include "biscuits.h" #include "bits/stdc++.h" #define MAXN 100009 #define INF 1000000007 #define mp(x,y) make_pair(x,y) #define all(v) v.begin(),v.end() #define pb(x) push_back(x) #define wr cout<<"----------------"<<endl; #define ppb() pop_back() #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++) #define ff first #define ss second #define my_little_dodge 46 #define debug(x) cerr<< #x <<" = "<< x<<endl; using namespace std; typedef long long ll; typedef pair<int,int> PII; template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} ll X; map<ll,ll>dp[61]; vector<ll>a; ll rec(int pos,ll cur){ if(pos==61)return 1; __typeof((dp[pos]).begin())it=dp[pos].lower_bound(cur),itt; if(it!=dp[pos].end()){ if(it->ff==cur)return it->ss;itt=it; if(itt!=dp[pos].begin()){ itt--;if(itt->ss==it->ss)return it->ss; } } ll &ret=dp[pos][cur]; ret=rec(pos+1,(cur+a[pos])/2); if(a[pos]+cur>=X)ret+=rec(pos+1,(a[pos]+cur-X)/2); it=dp[pos].upper_bound(cur); if(it!=dp[pos].end() and it->ss==ret){ itt=it;itt++; if(itt!=dp[pos].end() and itt->ss==ret) dp[pos].erase(it); }it--; if(it!=dp[pos].begin()){it--; if(it->ss==ret){ itt=it; if(itt!=dp[pos].begin()){itt--; if(itt->ss==ret) dp[pos].erase(it); } } } return ret; } long long count_tastiness(long long x, vector<long long> A) { X=x;a=A; for(int i=0;i<61;i++)dp[i].clear(); while(int(a.size())<61)a.pb(0); for(int i=0;i<60;i++) if(a[i]>x){ ll tmp=(a[i]-x)/2; a[i+1]+=tmp;a[i]-=tmp<<1; } return rec(0,0); }

Compilation message (stderr)

biscuits.cpp: In function 'll rec(int, ll)':
biscuits.cpp:28:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |   if(it->ff==cur)return it->ss;itt=it;
      |   ^~
biscuits.cpp:28:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   28 |   if(it->ff==cur)return it->ss;itt=it;
      |                                ^~~
#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...