Submission #1038805

#TimeUsernameProblemLanguageResultExecution timeMemory
1038805thinknoexitFlight to the Ford (BOI22_communication)C++17
15 / 100
20 ms2824 KiB
#include"communication.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void encode(int N, int X) {
    int x = X;
    int f = (3 ^ x) & 2;
    if (f == 0) {
        if (send(0) == 0) {
            if (send(0)) send((x & 1) ^ 1);
        }
        else {
            send((x & 1) ^ 1);
        }
    }
    else {
        if (send(1) == 1) send(0);
        else {
            send(1), send(0);
        }
    }
}
pair<int, int> ex[4] = { {0,0}, {2, 3}, {1, 3}, {1, 2} };
pair<int, int> decode(int N) {
    int val = 0;
    if (receive()) {
        val = 2 + receive();
        return ex[val];
    }
    if (!receive()) return ex[1];
    return ex[2 + receive()];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...