Submission #614277

# Submission time Handle Problem Language Result Execution time Memory
614277 2022-07-31T00:32:01 Z Plurm Flight to the Ford (BOI22_communication) C++17
0 / 100
574 ms 220 KB
#include "communication.h"
#include <bits/stdc++.h>
using namespace std;

int innersend(int bit) {
  int rec, last;
  if (bit) {
    rec = send(0);
    if (rec == 1)
      last = send(1);
    else {
      rec = send(0);
      if (rec == 1)
        last = send(1);
      else
        last = rec;
    }
  } else {
    rec = send(1);
    if (rec == 0)
      last = send(0);
    else {
      rec = send(1);
      if (rec == 0)
        last = send(0);
      else
        last = rec;
    }
  }
  return last;
}

void sendbit(int bit) {
  int last = 0;
  for (int tmt = 0; tmt < 81; tmt++) {
    if (bit) {
      last = innersend(last ^ 1);
    } else {
      last = innersend(last);
    }
  }
}

void encode(int N, int X) {
  // N = 3
  if (X == 2)
    sendbit(1);
  else
    sendbit(0);
}

int recbit() {
  int cnt[2];
  cnt[0] = cnt[1] = 0;
  for (int tmt = 0; tmt < 41; tmt++) {
    int last = receive();
    int cur = receive();
    while (last != cur) {
      last = cur;
      cur = receive();
    }
    cnt[cur]++;
  }
  for (int tmt = 0; tmt < 41; tmt++) {
    int last = receive();
    int cur = receive();
    while (last != cur) {
      last = cur;
      cur = receive();
    }
    cnt[cur]--;
  }
  return cnt[0] > cnt[1] ? 0 : 1;
}

std::pair<int, int> decode(int N) { return {1, (recbit() ? 2 : 3)}; }
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 220 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 574 ms 200 KB Not correct
2 Halted 0 ms 0 KB -