Submission #603917

# Submission time Handle Problem Language Result Execution time Memory
603917 2022-07-24T13:13:06 Z kostka Flight to the Ford (BOI22_communication) C++17
15 / 100
43 ms 1808 KB
#include "bits/stdc++.h"
#include "communication.h"

using namespace std;

const string codes[3] = {"0000", "0110", "1111"};

void encode(int N, int X) {
  assert(N <= 3);
  for (auto c : codes[X-1]) send(c-'0');
}

std::pair<int, int> decode(int N) {
  assert(N <= 3);
  string received;
  for (int i=0; i<4; i++) {
    received += to_string(receive());
  }
  set <int> S = {1, 2, 3};
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      // cerr << i << " " << j << " " << (codes[i][j] != received[j] and codes[i][j+1] != received[j+1]) << "\n";
      if (codes[i][j] != received[j] and codes[i][j+1] != received[j+1]) S.erase(i+1);
    }
  }
  assert(S.size() <= 2);
  vector <int> VS(S.begin(), S.end());
  return {VS[0], VS[1%VS.size()]};
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1808 KB Output is correct
2 Correct 10 ms 1720 KB Output is correct
3 Correct 11 ms 1708 KB Output is correct
4 Correct 10 ms 1708 KB Output is correct
5 Correct 16 ms 1768 KB Output is correct
6 Correct 31 ms 1744 KB Output is correct
7 Correct 43 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 328 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -