답안 #925541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925541 2024-02-12T01:47:55 Z dranjohn Flight to the Ford (BOI22_communication) C++17
15 / 100
20 ms 3204 KB
#include "communication.h"
#include <vector>

constexpr int B = 30;

int send_trit(int T) {
    int position = 0;
    int depth = 0;
    while (depth < 2) {
        int intent = 0;
        if (position % 3 != (T + 2) % 3) intent = 1;

        if (send(intent) == 0) ++position;
        else ++depth;

        //if (position == 4) return 2;
    }

    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;
        else ++depth;

        //if (position == 4) return 2;
    }

    return (position + 1) % 3;
}

std::pair<int, int> decode(int N) {
    int X = receive_trit();
    return { (X + 1) % 3 + 1, (X + 2) % 3 + 1 };
}

// g++ -std=c++17 sample_grader.cpp communication.cpp
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2740 KB Output is correct
2 Correct 6 ms 2764 KB Output is correct
3 Correct 6 ms 2740 KB Output is correct
4 Correct 4 ms 2732 KB Output is correct
5 Correct 4 ms 2776 KB Output is correct
6 Correct 14 ms 3116 KB Output is correct
7 Correct 20 ms 3204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 340 KB Not correct
2 Halted 0 ms 0 KB -