제출 #378234

#제출 시각아이디문제언어결과실행 시간메모리
378234Thistle비스킷 담기 (IOI20_biscuits)C++14
12 / 100
1032 ms14444 KiB
#include "biscuits.h" #include <vector> #include<iostream> #include<algorithm> #include<unordered_map> #include<map> using namespace std; using ll=long long; using H=pair<ll, ll>; using vi=vector<ll>; #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define rep(i,n) rng((i),(0),(n)) #define pb push_back #define vec vector #define all(a) (a).begin(),(a).end() #define fs first #define sc second #define siz(a) ll((a).size()) long long count_tastiness(long long x, std::vector<long long> a) { ll k=siz(a); a.resize(60); rng(i,k,60) a[i]=0; unordered_map<ll, ll>mp[61]; //remain cookie -> able number //i no jiten de no atai ga t ika dattara j made tobashimasu //i+1 ha t ijou no atai nara soko ni iku keishiki ni narimasu vec<vi> num(60),val(60); rep(i,60){ ll sum=0,mn=1e18; rng(j,i+1,60){ sum>>=1; sum+=a[j]; if(sum>=x){ num[i].pb(mn); val[i].pb(j); mn=-1; break; } else{ int g=0; rep(r,60) if(((x-sum)>>r)&1) g=r; if(g+(j-i)>=60) continue; ll t=(x-sum)<<(j-i); if(mn>=t){ num[i].pb(mn); val[i].pb(j); mn=t-1; } } } if(mn>=0){ num[i].pb(mn); val[i].pb(60); } } rep(i,60) { reverse(all(num[i])); reverse(all(val[i])); } mp[0][0]=1; rep(i,60){ auto& now=mp[i]; auto& nxt=mp[(i+1)]; for(auto g:now){ ll t=g.fs; t+=a[i]; int r=val[i][lower_bound(all(num[i]),t)-num[i].begin()]; mp[r][t>>(r-i)]+=g.sc; t-=x; if(t>=0){ r=val[i][lower_bound(all(num[i]),t)-num[i].begin()]; mp[r][t>>(r-i)]+=g.sc; } } } ll ans=0; for(auto g:mp[60]){ ans+=g.sc; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:11:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   11 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:25:2: note: in expansion of macro 'rng'
   25 |  rng(i,k,60) a[i]=0;
      |  ^~~
biscuits.cpp:11:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   11 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:12:18: note: in expansion of macro 'rng'
   12 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:32:2: note: in expansion of macro 'rep'
   32 |  rep(i,60){
      |  ^~~
biscuits.cpp:11:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   11 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:34:3: note: in expansion of macro 'rng'
   34 |   rng(j,i+1,60){
      |   ^~~
biscuits.cpp:11:28: warning: unnecessary parentheses in declaration of 'r' [-Wparentheses]
   11 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:12:18: note: in expansion of macro 'rng'
   12 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:45:5: note: in expansion of macro 'rep'
   45 |     rep(r,60) if(((x-sum)>>r)&1) g=r;
      |     ^~~
biscuits.cpp:11:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   11 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:12:18: note: in expansion of macro 'rng'
   12 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:61:2: note: in expansion of macro 'rep'
   61 |  rep(i,60) {
      |  ^~~
biscuits.cpp:11:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   11 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:12:18: note: in expansion of macro 'rng'
   12 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:67:2: note: in expansion of macro 'rep'
   67 |  rep(i,60){
      |  ^~~
biscuits.cpp:69:9: warning: unused variable 'nxt' [-Wunused-variable]
   69 |   auto& nxt=mp[(i+1)];
      |         ^~~
#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...