Submission #666366

# Submission time Handle Problem Language Result Execution time Memory
666366 2022-11-28T10:30:30 Z mychecksedad Flight to the Ford (BOI22_communication) C++17
Compilation error
0 ms 0 KB
#include"communication.h"
#include<bits/stdc++.h>
using namespace std;

void encode(int N, int X){
    for(int j = 0; j < 2; ++j){
        send(((1<<j)&X > 0));
        send(((1<<j)&X > 0));
    }
}
pair<int, int> decode(int N) {
    int a = 0, b = 0;

    int x[4];
    for(int j = 0; j < 4; ++j) x[j] = receive;

    if(x[0] == x[1]){
        a += 1;
        b += 1;
    }else if(x[0] != x[1]){
        a += 1;
    }
    if(x[2] == x[3]){
        a += 2;
        b += 2;
    }else if(x[2] != x[3]){
        b += 2;
    }

    return {a, b};
}

Compilation message

communication.cpp: In function 'void encode(int, int)':
communication.cpp:7:24: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    7 |         send(((1<<j)&X > 0));
      |                      ~~^~~
communication.cpp:8:24: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    8 |         send(((1<<j)&X > 0));
      |                      ~~^~~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:15:39: error: invalid conversion from 'int (*)()' to 'int' [-fpermissive]
   15 |     for(int j = 0; j < 4; ++j) x[j] = receive;
      |                                       ^~~~~~~
      |                                       |
      |                                       int (*)()