제출 #1353845

#제출 시각아이디문제언어결과실행 시간메모리
1353845lukaye_19Flight to the Ford (BOI22_communication)C++20
컴파일 에러
0 ms0 KiB
#include "communication.h"
#include <bits/stdc++.h>
using namespace std;

void encode(long long N,long long X)
{
    string binary = "";
    
    for (int i = 0; i < 30; i++)
    {
        int op = X % 2;
        
        X /= 2;
        
        binary.push_back((char)(op + '0'));
    }
    
    for (char x : binary)
    {
        int op = x - '0';
        
        if (op == 1)
        {
            send(1);
            send(0);
            send(0);
            send(1);
        }
        else
        {
            send(0);
            send(0);
            send(0);
            send(0);
        }
    }
}

pair<int,int> decode(long long N)
{
    string binary = "";
    
    for (int i = 0; i < 30; i++)
    {
        int a = recieve();
        int b = recieve();
        int c = recieve();
        ind d = recieve();
        
        vector<int>v = {a,b,c,d};
        
        int X;
        
        if (v[0] == v[3])
        {
            if (v[0] == 1) X = 2;
            else X = 1;
        }
        else if (v[0] == v[1])
        {
            X = 2;
        }
        else
        {
            X = 1;
        }
        
        X--;
        
        binary.push_back((char)(X + '0'));
    }
    
    long long R = 0;
    
    for (int i = 0; i < 30; i++)
    {
        R += (long long)pow(2,i) * (binary[i] - '0');
    }
    
    return {N,R};
}

컴파일 시 표준 에러 (stderr) 메시지

communication.cpp: In function 'std::pair<int, int> decode(long long int)':
communication.cpp:45:17: error: 'recieve' was not declared in this scope; did you mean 'receive'?
   45 |         int a = recieve();
      |                 ^~~~~~~
      |                 receive
communication.cpp:48:9: error: 'ind' was not declared in this scope; did you mean 'int'?
   48 |         ind d = recieve();
      |         ^~~
      |         int
communication.cpp:50:31: error: 'd' was not declared in this scope
   50 |         vector<int>v = {a,b,c,d};
      |                               ^
communication.cpp:50:32: error: could not convert '{a, b, c, <expression error>}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   50 |         vector<int>v = {a,b,c,d};
      |                                ^
      |                                |
      |                                <brace-enclosed initializer list>