Submission #875359

#TimeUsernameProblemLanguageResultExecution timeMemory
875359willychanShopping (JOI21_shopping)C++17
0 / 100
11 ms664 KiB
#include "Anna.h" #include <vector> #include<iostream> using namespace std; namespace { int triL[9]; int triR[9]; const int B = 51; int n, l, r; int count; int BTnum = 0; int BTind = 0; int RL[B]; int RR[B]; } // namespace void InitA(int N, int L, int R) { BTnum=0; BTind = 0; count=0; for(int i=0;i<9;i++){ triL[i]=0; triR[i]=0; } for(int i=0;i<B;i++){ RL[i]=0; RR[i]=0; } n = N; l = L; r = R; int bl = l/B; int br = r/B; for(int i=8;i>=0;i--){ triL[i] = (bl%3)-1; triR[i] = (br%3)-1; bl/=3; br/=3; } } void ReceiveA(bool x) { count++; if(count<=18){ int i = count-1; if(count<=9){ if(triL[i]>=0) SendA(triL[i]==1); }else{ if(triR[i]>=0) SendA(triR[i]==1); } }else{ if(count>=19 && count<=38){ BTnum<<=1; BTnum+=x; }else if(count>=39 && count<=58){ BTind<<=1; BTind+=x; }else{ if(count<=1078){ RL[((count-59)/20)]*=2; RL[((count-59)/20)]+=x; }else{ RR[((count-1079)/20)]*=2; RR[((count-1079)/20)]+=x; } } } } int Answer() { pair<int,int> minn = {1e9,-1}; minn = min(minn,{BTnum,BTind}); /* for(int i=0;i<B;i++) cout<<RL[i]<<" "; cout<<"L\n"; for(int i=0;i<B;i++) cout<<RL[i]<<" "; cout<<"R\n"; */ int rl = l%B; int rr = r%B; if(l/B==r/B){ for(int i=rl;i<=rr;i++) minn = min(minn,{RL[i],B*(l/B)+i}); }else{ for(int i=rl;i<B;i++) minn = min(minn,{RL[i],B*(l/B)+i}); for(int i=B-1;i>=rr;i--) minn = min(minn,{RR[i],B*(r/B)+i}); } return minn.second; }
#include "Bruno.h" #include <vector> #include<iostream> using namespace std; namespace { const int B = 51; int n; int arr[1000000]; int count; int ans = 0; bool FunctionExample(bool P) { return !P; } } // namespace void InitB(int N, std::vector<int> P) { n = N; for(int i = 0; i < N; i++) { arr[i] = P[i]; } int LB = 0; int RB = 0; for(int i=0;i<9;i++){ ans = -1; SendB(1); int tri = ans+1; LB*=3; LB+=tri; } for(int i=0;i<9;i++){ ans = -1; SendB(1); int tri = ans+1; RB*=3; RB+=tri; } int l = B*(LB+1); int r = B*(RB)-1; pair<int,int> BTnum = {1e9,1e9}; for(int i=l;i<=r && i<n;i++) BTnum = min(BTnum,{arr[i],i}); for(int i=19;i>=0;i--){ SendB((BTnum.first>>i)&1); } for(int i=19;i>=0;i--){ SendB((BTnum.second>>i)&1); } for(int i=0;i<B;i++){ int loc = i+B*(LB); int G = (1<<20)-1; if(loc<n) G = arr[loc]; for(int i=19;i>=0;i--){ SendB((G>>i)&1); } } for(int i=0;i<B;i++){ int loc = i+B*(RB); int G = (1<<20)-1; if(loc<n) G = arr[loc]; for(int i=19;i>=0;i--){ SendB((G>>i)&1); } } } void ReceiveB(bool y) { ans = (int)y; }

Compilation message (stderr)

Bruno.cpp:11:6: warning: 'bool {anonymous}::FunctionExample(bool)' defined but not used [-Wunused-function]
   11 | bool FunctionExample(bool P) {
      |      ^~~~~~~~~~~~~~~
Bruno.cpp:9:5: warning: '{anonymous}::count' defined but not used [-Wunused-variable]
    9 | int count;
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...