답안 #1099059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099059 2024-10-10T12:54:41 Z LIA Flight to the Ford (BOI22_communication) C++17
0 / 100
10 ms 332 KB
#include "communication.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vector<pll>> vvpll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
const ll inf = 1e9 + 7;

void encode(int N, int X) {
    vector<int> signals(3);

    if (X == 1) {
        signals[0] = 0;
        signals[1] = 0;
        signals[2] = 0;
    } else if (X == 2) {
        signals[0] = 0;
        signals[1] = 1;
        signals[2] = 0;
    } else if (X == 3) {
        signals[0] = 1;
        signals[1] = 0;
        signals[2] = 0;
    }

    for (int i = 0; i < signals.size(); ++i) {
        send(signals[i]);
    }
}

pair<int, int> decode(int N) {
    vector<int> receivedSignals(3);

    for (int i = 0; i < receivedSignals.size(); ++i) {
        receivedSignals[i] = receive();
    }

    if (receivedSignals[0] == 0 && receivedSignals[1] == 0) {
        return {1, 2};
    } else if (receivedSignals[0] == 0 && receivedSignals[1] == 1) {
        return {2, 3};
    } else if (receivedSignals[0] == 1 && receivedSignals[1] == 0) {
        return {3, 1};
    } else {
        return {1, 1};
    }
}

Compilation message

communication.cpp: In function 'void encode(int, int)':
communication.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < signals.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~~~
communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < receivedSignals.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 332 KB Not correct
2 Halted 0 ms 0 KB -