답안 #666604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
666604 2022-11-29T07:00:46 Z mychecksedad Flight to the Ford (BOI22_communication) C++17
컴파일 오류
0 ms 0 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;
            }
            m.clear();
            if(ok){
                a = j + 1;
                b = i + 1;
                return {a, b};
            }
        }
        return {j + 1, j + 1};
    }


    return {1, 3};
}

Compilation message

communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:75:16: error: 'ok' was not declared in this scope
   75 |             if(ok){
      |                ^~