제출 #378249

#제출 시각아이디문제언어결과실행 시간메모리
378249Thistle비스킷 담기 (IOI20_biscuits)C++14
0 / 100
1095 ms293884 KiB
#include "biscuits.h" #include <vector> #include<iostream> #include<algorithm> #include<unordered_map> #include<queue> #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> csum(60,vi(60,0)); rep(i,60){ ll sum=0; rng(j,i+1,60){ sum>>=1; sum+=a[j]; csum[i][j]=sum; } } vec<vi> num(60),val(60); rep(i,60){ ll sum=0,mn=1000000000000000000; 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=-100; 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])); } queue<ll>q[60]; q[0].push(a[0]); ll ans=0; rep(i,60){ while(!q[i].empty()){ ll t=q[i].front();q[i].pop(); int r=val[i][lower_bound(all(num[i]),t)-num[i].begin()]; if(r==60) ans++; else { q[r].push(t>>(r-i)+csum[i][r]); } if(t<x) continue; t-=x; r=val[i][lower_bound(all(num[i]),t)-num[i].begin()]; if(r==60) ans++; else { q[r].push(t>>(r-i)+csum[i][r]); } } } return ans; }

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

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:26:2: note: in expansion of macro 'rng'
   26 |  rng(i,k,60) a[i]=0;
      |  ^~~
biscuits.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:13:18: note: in expansion of macro 'rng'
   13 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:33:2: note: in expansion of macro 'rep'
   33 |  rep(i,60){
      |  ^~~
biscuits.cpp:12:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   12 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:35:3: note: in expansion of macro 'rng'
   35 |   rng(j,i+1,60){
      |   ^~~
biscuits.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:13:18: note: in expansion of macro 'rng'
   13 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:42:2: note: in expansion of macro 'rep'
   42 |  rep(i,60){
      |  ^~~
biscuits.cpp:12:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   12 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:44:3: note: in expansion of macro 'rng'
   44 |   rng(j,i+1,60){
      |   ^~~
biscuits.cpp:12:28: warning: unnecessary parentheses in declaration of 'r' [-Wparentheses]
   12 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:13:18: note: in expansion of macro 'rng'
   13 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:55:5: note: in expansion of macro 'rep'
   55 |     rep(r,60) if(((x-sum)>>r)&1) g=r;
      |     ^~~
biscuits.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:13:18: note: in expansion of macro 'rng'
   13 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:71:2: note: in expansion of macro 'rep'
   71 |  rep(i,60) {
      |  ^~~
biscuits.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
biscuits.cpp:13:18: note: in expansion of macro 'rng'
   13 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
biscuits.cpp:78:2: note: in expansion of macro 'rep'
   78 |  rep(i,60){
      |  ^~~
biscuits.cpp:84:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   84 |     q[r].push(t>>(r-i)+csum[i][r]);
biscuits.cpp:91:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   91 |     q[r].push(t>>(r-i)+csum[i][r]);
#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...