답안 #614270

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
614270 2022-07-31T00:25:35 Z Plurm Flight to the Ford (BOI22_communication) C++17
0 / 100
555 ms 1708 KB
#include "communication.h"
#include <bits/stdc++.h>
using namespace std;

void sendbit(int bit) {
  for (int tmt = 0; tmt < 33; tmt++) {
    int rec;
    if (bit) {
      rec = send(0);
      if (rec == 1)
        send(1);
      else {
        rec = send(0);
        if (rec == 1)
          send(1);
      }
    } else {
      rec = send(1);
      if (rec == 0)
        send(0);
      else {
        rec = send(1);
        if (rec == 0)
          send(0);
      }
    }
  }
  for (int tmt = 0; tmt < 33; tmt++) {
    int rec;
    if (!bit) {
      rec = send(0);
      if (rec == 1)
        send(1);
      else {
        rec = send(0);
        if (rec == 1)
          send(1);
      }
    } else {
      rec = send(1);
      if (rec == 0)
        send(0);
      else {
        rec = send(1);
        if (rec == 0)
          send(0);
      }
    }
  }
}

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 < 33; tmt++) {
    int last = receive();
    int cur = receive();
    while (last != cur) {
      last = cur;
      cur = receive();
    }
    cnt[cur]++;
  }
  for (int tmt = 0; tmt < 33; 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)}; }
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 1708 KB Output is correct
2 Incorrect 52 ms 200 KB Not correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 555 ms 220 KB Not correct
2 Halted 0 ms 0 KB -