답안 #925469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925469 2024-02-11T17:25:47 Z dranjohn Flight to the Ford (BOI22_communication) C++17
15 / 100
25 ms 3112 KB
#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 };
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2952 KB Output is correct
2 Correct 11 ms 2748 KB Output is correct
3 Correct 9 ms 2760 KB Output is correct
4 Correct 2 ms 3112 KB Output is correct
5 Correct 7 ms 2920 KB Output is correct
6 Correct 13 ms 2888 KB Output is correct
7 Correct 25 ms 2768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 332 KB Not correct
2 Halted 0 ms 0 KB -