Submission #582155

# Submission time Handle Problem Language Result Execution time Memory
582155 2022-06-23T12:50:00 Z KoD Flight to the Ford (BOI22_communication) C++17
15 / 100
44 ms 1868 KB
#include "communication.h"
#include <bits/stdc++.h>

using std::vector;

int A[4][4] = {
    {-1, -1, -1, -1},
    {0, 0, 0, 0},
    {0, 1, 1, 0},
    {1, 1, 1, 1}
};

void encode(int N, int X) {
    for (int i = 0; i < 4; ++i) {
        send(A[X][i]);
    }
}

std::pair<int, int> decode(int N) {
    vector<int> vec;
    for (int i = 0; i < 4; ++i) {
        vec.push_back(receive());
    }
    for (int i = 1; i <= 3; ++i) {
        bool f = false;
        for (const int ch : {0, 1, 2, 4, 8, 5, 9, 10}) {
            vector<int> a(4);
            for (int j = 0; j < 4; ++j) {
                a[j] = A[i][j] ^ (ch >> j & 1);
            }
            if (a == vec) {
                f = true;
                break;
            }
        }
        if (!f) {
            if (i == 1) return {2, 3};
            if (i == 2) return {1, 3};
            if (i == 3) return {1, 2};
        }
    }
    return {-1, -1};
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1772 KB Output is correct
2 Correct 13 ms 1720 KB Output is correct
3 Correct 18 ms 1732 KB Output is correct
4 Correct 12 ms 1784 KB Output is correct
5 Correct 12 ms 1684 KB Output is correct
6 Correct 27 ms 1868 KB Output is correct
7 Correct 44 ms 1704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -