이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "communication.h"
#include <iostream>
#include <vector>
int send_trit(int T) {
    int position = 0;
    int depth = 0;
    while (depth < 2) {
        int intent = 0;
        if (position != (T + 2) % 3) intent = 1;
        if (send(intent) == 0) {
            ++position;
            position %= 3;
        }
        else ++depth;
    }
    return (position + 1) % 3;
}
void encode(int N, int X) {
    --X;
    if (N > 3) return;
    send_trit(X);
}
int receive_trit() {
    int position = 0;
    int depth = 0;
    while (depth < 2) {
        if (receive() == 0) {
            ++position;
            position %= 3;
        }
        else ++depth;
    }
    return (position + 1) % 3;
}
std::pair<int, int> decode(int N) {
    int X = receive_trit();
    return { (X + 1) % 3 + 1, (X + 2) % 3 + 1 };
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |