Submission #666605

# Submission time Handle Problem Language Result Execution time Memory
666605 2022-11-29T07:01:17 Z mychecksedad Flight to the Ford (BOI22_communication) C++17
15 / 100
49 ms 1828 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){
    if(X == 1){
        send(0);
        send(0);
        send(0);
        send(0);
    }
    if(X == 2){
        send(0);
        send(1);
        send(1);
        send(0);
    }
    if(X == 3){
        send(1);
        send(1);
        send(1);
        send(1);
    }
}
pair<int, int> decode(int N) {
    int a = 0, b = 0, x = 0;

    int y[3] = {0, 6, 15};
    
    for(int j = 0; j < 4; ++j) x += receive() * (1<<j);
    
    map<int, bool> m;
    
    auto corrupt = [&](int n){
        m[n^1] = 1;
        m[n^2] = 1;
        m[n^4] = 1;
        m[n^8] = 1;
        m[n^5] = 1;
        m[n^9] = 1;
        m[n^10] = 1;
        m[n] = 1;
    };
    for(int j = 0; j < 3; ++j){
        corrupt(y[j]);
        if(!m[x]){
            m.clear();
            continue;
        }
        m.clear();
        for(int i = 0; i < 3; ++i){
            if(i==j) continue;
            corrupt(y[i]);
            if(!m[x]){
                m.clear();
                continue;
            }
            a = j + 1;
            b = i + 1;
            return {a, b};
        }
        return {j + 1, j + 1};
    }


    return {1, 3};
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1700 KB Output is correct
2 Correct 11 ms 1688 KB Output is correct
3 Correct 18 ms 1772 KB Output is correct
4 Correct 10 ms 1680 KB Output is correct
5 Correct 14 ms 1756 KB Output is correct
6 Correct 27 ms 1828 KB Output is correct
7 Correct 49 ms 1712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 200 KB Not correct
2 Halted 0 ms 0 KB -