Submission #921834

# Submission time Handle Problem Language Result Execution time Memory
921834 2024-02-04T11:19:42 Z guagua0407 Shopping (JOI21_shopping) C++17
0 / 100
6 ms 5012 KB
#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() {
    assert(ans!=0);
    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

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 time Memory Grader output
1 Correct 5 ms 4760 KB Output is correct
2 Correct 6 ms 4760 KB Output is correct
3 Correct 4 ms 5012 KB Output is correct
4 Correct 5 ms 4760 KB Output is correct
5 Correct 4 ms 4760 KB Output is correct
6 Correct 4 ms 4760 KB Output is correct
7 Correct 5 ms 4760 KB Output is correct
8 Correct 5 ms 4760 KB Output is correct
9 Incorrect 3 ms 332 KB Wrong Answer [1]
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4760 KB Output is correct
2 Correct 6 ms 4760 KB Output is correct
3 Correct 4 ms 5012 KB Output is correct
4 Correct 5 ms 4760 KB Output is correct
5 Correct 4 ms 4760 KB Output is correct
6 Correct 4 ms 4760 KB Output is correct
7 Correct 5 ms 4760 KB Output is correct
8 Correct 5 ms 4760 KB Output is correct
9 Incorrect 3 ms 332 KB Wrong Answer [1]
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 396 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -