Submission #666371

# Submission time Handle Problem Language Result Execution time Memory
666371 2022-11-28T10:35:52 Z mychecksedad Flight to the Ford (BOI22_communication) C++17
0 / 100
21 ms 200 KB
#include <utility>
#include <bits/stdc++.h>
using namespace std;
/**
 * use this function in encode when you want to send a certain signal
 * (it might come out wrong, and the return value tells you which signal
 * was actually sent)
 */
int send(int);

/**
 * use this function in decode; it returns the next signal that was actually
 * sent during the corresponding call of encode
 */
int receive();

/**
 * implement these two functions yourself
 */

void encode(int N, int X){
    for(int j = 0; j < 2; ++j){
        bool val = (1<<j)&X;
        send(val);
        send(val);
    }
}
pair<int, int> decode(int N) {
    int a = 0, b = 0;

    int x[4];
    for(int j = 0; j < 4; ++j) x[j] = receive();

    if(x[0] == x[1]){
        if(x[0] == 1){
            a += 1;
            b += 1;
        }
    }else if(x[0] != x[1]){
        a += 1;
    }
    if(x[2] == x[3]){
        if(x[2] == 1){
            a += 2;
            b += 2;
        }
    }else if(x[2] != x[3]){
        b += 2;
    }
    if(x[0] != x[1] && x[2] != x[3]) a = b = 3;

    return {a, b};
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 200 KB Not correct
2 Halted 0 ms 0 KB -