Submission #580153

# Submission time Handle Problem Language Result Execution time Memory
580153 2022-06-20T16:18:44 Z wiwiho Flight to the Ford (BOI22_communication) C++17
15 / 100
45 ms 1808 KB
#include"communication.h"

#include <bits/stdc++.h>

#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
#define eb emplace_back
#define ef emplace_front
#define pob pop_back()
#define pof pop_front()
#define mp make_pair
#define F first
#define S second
#define uni(a) a.resize(unique(iter(a)) - a.begin())
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

typedef long long ll;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

const int SZ = 4;

void encode(int N, int X) {
    auto owo = [&](int t){
        for(int i = 0; i < SZ; i++){
            if(1 << i & t) send(1);
            else send(0);
        }
    };

    if(X == 1) owo(0b0000);
    if(X == 2) owo(0b0110);
    if(X == 3) owo(0b1001);
}

pii decode(int N) {
    int X = 0;
    for(int i = 0; i < SZ; i++){
        if(receive()) X |= 1 << i;
    }

    vector<int> ans;
    int n = 1 << SZ;
    for(int i = 0; i < n; i++){
        bool ok = true;
        for(int j = 0; j + 1 < SZ; j++){
            if((1 << j & i) && (1 << (j + 1) & i)) ok = false;
        }
        if(!ok) continue;
        int tmp = X ^ i;
        if(tmp == 0b0000) ans.eb(1);
        else if(tmp == 0b0110) ans.eb(2);
        else if(tmp == 0b1001) ans.eb(3);
    }
    while(ans.size() < 2) ans.eb(1);

    return {ans[0], ans[1]};
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1748 KB Output is correct
2 Correct 12 ms 1680 KB Output is correct
3 Correct 15 ms 1772 KB Output is correct
4 Correct 11 ms 1800 KB Output is correct
5 Correct 14 ms 1684 KB Output is correct
6 Correct 32 ms 1808 KB Output is correct
7 Correct 45 ms 1740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 200 KB Not correct
2 Halted 0 ms 0 KB -