Submission #1103078

# Submission time Handle Problem Language Result Execution time Memory
1103078 2024-10-19T23:15:18 Z aaaaaarroz Message (IOI24_message) C++17
0 / 100
485 ms 420 KB
#include <bits/stdc++.h>
using namespace std;
vector<bool> send_packet(vector<bool> A);
void send_message(vector<bool> M, vector<bool> C) {
    vector<bool> enviar(31);
    int pos = 0;
    int cnt = 0;
    for (int i = 0; i < 25; i++) {
        vector<bool> control_packet(31, !C[i]);
        send_packet(control_packet);
    }
    int cantidad = M.size();
    int bit = 0;
    for (int i = 0; i < 31; i++) {
        if (!C[i] && bit < 6) {
            enviar[i] = (cantidad >> bit) & 1; 
            bit++;
        } else {
            enviar[i] = 0;
        }
    }
    send_packet(enviar);  
    vector<bool> envio(31);
    int msg_pos = 0;
    while (msg_pos < M.size()) {
        int envio_pos = 0;
        for (int i = 0; i < 31; i++) {
            if (!C[i] && msg_pos < M.size()) {
                envio[i] = M[msg_pos];  
                msg_pos++;
            } else {
                envio[i] = 0;  
            }
        }
        send_packet(envio); 
    }
}
vector<bool> receive_message(vector<vector<bool>> R) {
    vector<bool> funciona(31, false);
    int paquetes = R.size();
    for (int i = 0; i < 25; i++) {
        int votos = 0;
        for (int j = 0; j < 31; j++) {
            if (R[i][j]) votos++;
        }
        if (votos > 15) {
            funciona[i] = true;  
        }
    }
    int bit_real = 0;
    int largo = 0;
    for (int i = 0; i < 31; i++) {
        if (!funciona[i] && bit_real < 6) {
            largo += (R[25][i] << bit_real); 
            bit_real++;
        }
    }
    vector<bool> sec;
    for (int i = 26; i < paquetes; i++) {
        for (int j = 0; j < 31; j++) {
            if (!funciona[j]) {
                sec.push_back(R[i][j]);  
            }
        }
    }
    while (sec.size() > largo) {
        sec.pop_back();
    }
    return sec;  
}

Compilation message

message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     while (msg_pos < M.size()) {
      |            ~~~~~~~~^~~~~~~~~~
message.cpp:28:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             if (!C[i] && msg_pos < M.size()) {
      |                          ~~~~~~~~^~~~~~~~~~
message.cpp:26:13: warning: unused variable 'envio_pos' [-Wunused-variable]
   26 |         int envio_pos = 0;
      |             ^~~~~~~~~
message.cpp:6:9: warning: unused variable 'pos' [-Wunused-variable]
    6 |     int pos = 0;
      |         ^~~
message.cpp:7:9: warning: unused variable 'cnt' [-Wunused-variable]
    7 |     int cnt = 0;
      |         ^~~
message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:66:23: warning: comparison of integer expressions of different signedness: 'std::vector<bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |     while (sec.size() > largo) {
      |            ~~~~~~~~~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB decoded message is incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 485 ms 420 KB decoded message is incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB decoded message is incorrect
2 Halted 0 ms 0 KB -