Submission #921828

#TimeUsernameProblemLanguageResultExecution timeMemory
921828guagua0407Shopping (JOI21_shopping)C++17
0 / 100
5 ms5012 KiB
#include "Anna.h" #include <bits/stdc++.h> namespace { int n, L, R; int count; int cur=0; int bit=0; int a=0,b=0; int ind[3]; int timer=0; int ans=0; int now=0; bool ok=false; void comp(){ if(L<=a or b<=R){ a=0,b=0,bit=0; timer++; cur=0; if(timer==18) cur=2; SendA(1); } else{ a=0,b=0,bit=0; timer++; cur=0; if(timer==18) cur=2; SendA(0); } } void comp2(){ if(a<L and R<b){ ans=ind[2]; ok=true; a=0,b=0,bit=0; cur=5; } else{ a=0,b=0,bit=0; cur=5; } } void comp3(){ if(a<L and R<b){ if(!ok) ans=ind[1]; } else{ if(!ok) ans=ind[0]; } } } // namespace void InitA(int N, int L, int R) { ::n = N; ::L = L+1; ::R = R+1; } void ReceiveA(bool x) { if(cur==0){ a+=x*(1<<bit); bit++; if(bit==20){ cur=1; bit=0; } } else if(cur==1){ b+=x*(1<<bit); bit++; if(bit==20){ comp(); } } else if(cur==2){ ind[now]+=x*(1<<bit); bit++; if(bit==20){ bit=0; if(now==2){ cur=3; } else{ now++; } } } else if(cur==3){ a+=x*(1<<bit); bit++; if(bit==20){ cur=4; bit=0; } } else if(cur==4){ b+=x*(1<<bit); bit++; if(bit==20){ comp2(); } } else if(cur==5){ a+=x*(1<<bit); bit++; if(bit==20){ cur=6; bit=0; } } else if(cur==6){ b+=x*(1<<bit); bit++; if(bit==20){ comp3(); } } } int Answer() { return ans-1; }
#include "Bruno.h" #include <bits/stdc++.h> namespace { int n; bool ok; const int mxn=1e6+5; int variable_example[1000000]; int L[mxn],R[mxn],rev[mxn]; int l,r; int mid; int timer=0; int count; bool FunctionExample(bool P) { return !P; } void send(int x){ for(int i=0;i<20;i++){ if(x&(1<<i)) SendB(1); else SendB(0); } } void check(int mid){ send(L[mid]); send(R[mid]); } void sir(){ mid=(l+r+1)/2; timer++; check(mid); } void get(){ //std::cout<<mid<<' '<<ok<<'\n'; if(ok){ if(l<r) r=mid-1; } else{ if(l<r) l=mid; } if(timer<18){ sir(); } else{ //std::cout<<l<<'\n'; send(rev[l]); send(rev[l+1]); send(rev[l+2]); send(L[l+2]); send(R[l+2]); send(L[l+1]); send(R[l+1]); } } } // namespace void InitB(int N, std::vector<int> vec) { ::n=N; std::set<int> S; for(int i=1;i<=n;i++){ rev[vec[i-1]]=i; } for(int i=1;i<=n;i++){ S.insert(i); } for(int i=n;i>=1;i--){ S.erase(rev[i]); auto it=S.lower_bound(rev[i]); if(it!=S.end()){ R[i]=*it; } else{ R[i]=n+1; } if(!S.empty() and it!=S.begin()){ L[i]=*prev(it); } else{ L[i]=0; } } L[n+1]=n+1,R[n+1]=0; L[n+2]=n+1,R[n+2]=0; for(int i=1;i<=n;i++){ //std::cout<<L[i]<<' '<<R[i]<<'\n'; } l=1,r=n; sir(); } void ReceiveB(bool y) { ok=y; get(); }

Compilation message (stderr)

Anna.cpp:7:5: warning: '{anonymous}::count' defined but not used [-Wunused-variable]
    7 | int count;
      |     ^~~~~

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