Submission #728473

# Submission time Handle Problem Language Result Execution time Memory
728473 2023-04-22T13:16:33 Z Charizard2021 Flight to the Ford (BOI22_communication) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
mt19937 rngQ(23478123);

long long K = rngQ();

void encode(int N, int X) {
    vector <long long> v(250, -1);
    vector < long long > b1, b2;
    long long mx = 130;
    mt19937 rng(K);
    for(long long i = 0; i < 250; i++){
        if(rng() % 3 == 1 && (!i || v[i - 1] == -1) ){
            mx--;
            v[i] = rng()%2;
        }else{
            if(rng()%2){
                b1.push_back(i);
            }
            else{
                b2.push_back(i);
            }
        }
    }
    for(auto u : b1) v[u] = (1 << 0) & X;
    for(auto u : b2) v[u] = (X >> 1) & 1;
    for(auto u : v){
        send(u);
    }
    return;
}

std::pair<int, int> decode(int N) {
    vector <long long> v(250, -1);
    long long mx = 130;
    mt19937 rng2(K);
    vector < long long > rem, b1, b2;
    for(long long i = 0; i < 250; i++){
        if(rng2() % 3 == 1 && (!i || v[i - 1] == -1) ){
            mx--;
            v[i] = rng2() % 2;
        }else{
            if(rng2() % 2){
                b1.push_back(i);
            }
            else{
                b2.push_back(i);
            }
        }
    }
    vector < long long > g(250);
    for(long long i = 0; i < 250; i++){
        g[i] = receive();
    }
    long long works = 0;
    long long flag1 = 0;
    long long flag2 = 0;
    long long value2 = 0;
    long long value3 = 0;
    for(auto u : b1){
        if(u && v[u - 1] != -1 && v[u - 1] != g[u - 1]){
            works |= g[u];
            flag1 = 1;
        }
        if(u + 1 < 250 && v[u + 1] != -1 && v[u + 1] != g[u + 1]){
            works |= g[u];
            flag1 = 1;
        }
        value2 += (g[u] == 0 ? -1 : 1);
    }
    for(auto u : b2){
        if(u && v[u - 1] != -1 && v[u - 1] != g[u - 1]) works |= (g[u] << 1), flag2 = 1;
        if(u + 1 < 250 && v[u + 1] != -1 && v[u + 1] != g[u + 1]) works |= (g[u] << 1), flag2 = 1;
        value3 += (g[u] == 0 ? -1 : 1);
    }
    long long a1 = works, a2 = works;
    if(!flag1 && !flag2){
        if(max(value2, value3) == value2){
            if(value2 >= 0) a1 |= 1, a2 |= 1;
            if(value3 >= 0) a2 |= 2;
        }else{
            if(value3 >= 0) a1 |= 2, a2 |= 2;
            if(value2 >= 0) a1 |= 1;
        }
    }else{
        if(!flag1 && value2 >= 0){
            a1 |= 1;
        }
        if(!flag2 && value3 >= 0){
            a1 |= 2;
        }
    }
    a1 = min((int)a1, N);
    a1 = max(1, (int)a1);
    a2 = max(1, (int)a2);
    a2 = min((int)a2, N);
    while(a1 == a2){
        a1++;
        if(a1 == N+1){
            a1 = 1;
        }
    }
    return {a1, a2};
}

Compilation message

communication.cpp: In function 'void encode(int, int)':
communication.cpp:28:9: error: 'send' was not declared in this scope
   28 |         send(u);
      |         ^~~~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:53:16: error: 'receive' was not declared in this scope
   53 |         g[i] = receive();
      |                ^~~~~~~