Submission #1187185

#TimeUsernameProblemLanguageResultExecution timeMemory
1187185DanielPr8Flight to the Ford (BOI22_communication)C++20
0 / 100
11 ms2732 KiB
#include <bits/stdc++.h>
#include"communication.h"

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvl = vector<vll>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvp = vector<vpl>;

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(),v.end()
//     g++ -std=c++17 communication_sample.cpp sample_grader.cpp
// as ./a.exe

void encode(int n, int x) {
    for(ll i = 0; i < 30; ++i){
        if(send(0)==1)break;
    }
    if(x & (1<<0))send(1);
    else send(0);
    for(ll i = 0; i < 30; ++i){
        if(send(0)==1)break;
    }
    if(x & (1<<1))send(1);
    else send(0);
}

std::pair<int, int> decode(int N) {
    ll x = 0;
    for(ll i = 0; i < 30; ++i){
        if(receive()==1)break;
    }
    x += (receive());
    for(ll i = 0; i < 30; ++i){
        if(receive()==1)break;
    }
    x += (receive()*2);
    return {x, x%3+1};
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...