Submission #436599

#TimeUsernameProblemLanguageResultExecution timeMemory
436599Mamnoon_SiamShopping (JOI21_shopping)C++17
10 / 100
115 ms812 KiB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second

namespace {

int N, L, R;
vi bits;
const int magic = 20;
int where = 0;

}  // namespace

void InitA(int N, int L, int R) {
  ::N = N;
  ::L = L;
  ::R = R;
  int LB = L / magic;
  int RB = R / magic;
  for(int i = 0; i < 9; ++i) {
    SendA(LB >> i & 1);
  }
  for(int i = 0; i < 9; ++i) {
    SendA(RB >> i & 1);
  }
  int cnt = 0;
  for(int i = LB*magic; i < min(N, (LB+1)*magic); ++i) {
    for(int j = RB*magic; j < min(N, (RB+1)*magic); ++j) {
      if(i == L and j == R) {
        where = cnt;
      }
      cnt++;
    }
  }
}

void ReceiveA(bool x) {
  bits.emplace_back(x);
}

int Answer() {
  int ret = 0;
  for(int i = 0; i < 14; ++i) {
    if(bits[14*where+i]) ret |= (1 << i);
  }
  return ret;
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second

namespace {

const int magic = 20;
int N;

int cnt = 0;
int LB = 0, RB = 0;
vi P;

}  // namespace

void InitB(int N, std::vector<int> P) {
  ::N = N;
  ::P = P;
}

void ReceiveB(bool y) {
  if(cnt < 9) {
    LB |= (int(y) << cnt);
  } else {
    RB |= (int(y) << (cnt - 9));
  }
  cnt++;
  if(cnt == 18) {
    for(int i = LB*magic; i < min(N, (LB+1)*magic); ++i) {
      for(int j = RB*magic; j < min(N, (RB+1)*magic); ++j) {
        ii mn = {INT_MAX, INT_MAX};
        for(int x = i; x <= j; ++x) {
          mn = min(mn, ii(P[x], x));
        }
        for(int x = 0; x < 14; ++x) {
          SendB(mn.se >> x & 1);
        }
      }
    }
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...