답안 #1104394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104394 2024-10-23T15:11:55 Z fve5 Flight to the Ford (BOI22_communication) C++17
15 / 100
44 ms 3252 KB
#include <bits/stdc++.h>
#include "communication.h"
using namespace std;

void encode(int N, int X) {
    assert(N == 3);
    
    switch (--X) {
    case 0: send(0), send(0), send(0), send(0); break;
    case 1: send(0), send(1), send(1), send(0); break;
    case 2: send(1), send(0), send(0), send(1); break;
    }
}

constexpr int LEN = 4;

pair<int, int> starting_guesses(vector<int> packet) {
    int val = packet[0] | 2 * packet[1] | 4 * packet[2] | 8 * packet[3];
    switch (val) {
        case  0: return {0, 2};
        case  1: return {0, 2};
        case  2: return {0, 1};
        case  3: return {1, 2};
        case  4: return {0, 1};
        case  5: return {0, 0};
        case  6: return {1, 1};
        case  7: return {1, 1};
        case  8: return {0, 2};
        case  9: return {0, 2};
        case 10: return {0, 0};
        case 11: return {2, 2};
        case 12: return {1, 2};
        case 13: return {2, 2};
        case 14: return {1, 1};
        case 15: return {1, 1};
    }
}

pair<int, int> decode(int N) {
    vector<int> message(LEN);
    for (auto &x: message) x = receive();

    auto [guess_1, guess_2] = starting_guesses(vector(message.end() - 4, message.end()));

    return {min(N, guess_1 + 1), min(N, guess_2 + 1)};
}

Compilation message

communication.cpp: In function 'std::pair<int, int> starting_guesses(std::vector<int>)':
communication.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2808 KB Output is correct
2 Correct 14 ms 2744 KB Output is correct
3 Correct 16 ms 2724 KB Output is correct
4 Correct 12 ms 2732 KB Output is correct
5 Correct 14 ms 3252 KB Output is correct
6 Correct 25 ms 2984 KB Output is correct
7 Correct 44 ms 2708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 584 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -