Submission #1050556

#TimeUsernameProblemLanguageResultExecution timeMemory
1050556That_SalamanderFlight to the Ford (BOI22_communication)C++17
15 / 100
19 ms3120 KiB
#include <bits/stdc++.h>

#include "communication.h"

using namespace std;

int answer[3][4] = {{0, 0, 0, 0}, {0, 1, 1, 0}, {1, 1, 1, 1}};

void encode(int n, int x) {

    for (int x: answer[x-1]) {
        send(x);
    }
}

int corruptible(int* a, int* b, int size) {
    bool canCorrupt = true;
    for (int i = 0; i < size; i++) {
        if (a[i] != b[i]) {
            if (!canCorrupt) return false;
            canCorrupt = false;
        } else {
            canCorrupt = true;
        }
    }

    return true;
}

pair<int, int> decode(int n) {
    int res[4];
    for (int& x: res) x = receive();

    vector<int> poss;
    for (int i = 0; i < 3; i++) {
        if (corruptible(res, answer[i], 4)) {
            poss.push_back(i+1);
        }
    }
    poss.push_back(1);

    return {poss[0], poss[1]};
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...