Submission #1108901

# Submission time Handle Problem Language Result Execution time Memory
1108901 2024-11-05T15:54:33 Z Ghulam_Junaid Message (IOI24_message) C++17
79.6403 / 100
2870 ms 1088 KB
#include <bits/stdc++.h>
#include "message.h"
using namespace std;

void send_message(vector<bool> M, vector<bool> C) {
    vector<int> allowed;
    for (int i = 0; i < 31; i ++)
        if (!C[i])
            allowed.push_back(i);

    int fbit = allowed[0];
    for (int i = 0; i < 4; i ++){
        if ((1 << i) & fbit){
            vector<bool> A(31, 1);
            send_packet(A);
        }
        else{
            vector<bool> A(31, 0);
            send_packet(A);
        }
    }

    int p = 0;
    vector<bool> A(31, 0);
    for (int i = 0; i < 31; i ++){
        if (C[i])
            A[fbit] = 1;
        else
            A[fbit] = 0;

        for (int j = 1; j < allowed.size(); j ++){
            A[allowed[j]] = M[p % M.size()]; 
            p++;
        }
        send_packet(A);
    }

    for (int i = 0; i < allowed.size(); i ++){
        if ((1 << i) & M.size())
            A[allowed[i]] = 1;
        else
            A[allowed[i]] = 0;
    }
    send_packet(A);

    while (p < M.size()){
        for (int j = 0; j < allowed.size(); j ++){
            A[allowed[j]] = M[p % M.size()]; 
            p++;
        }
        send_packet(A);
    }
}

vector<bool> receive_message(vector<vector<bool>> R) {
    int fbit = 0;
    int q = 0;

    for (int i = q; i < q + 4; i ++){
        int cnt = 0;
        for (bool x : R[i])
            cnt += x;
        if (cnt >= 16)
            fbit += (1 << i);
    }
    q += 4;

    vector<int> allowed;
    for (int i = q; i < q + 31; i ++)
        if (!R[i][fbit])
            allowed.push_back(i - 4);

    vector<bool> res;
    for (int i = q; i < q + 31; i ++){
        for (int j = 1; j < allowed.size(); j ++){
            res.push_back(R[i][allowed[j]]);
        }
    }

    q += 31;

    int sz = 0;
    for (int i = 0; i < allowed.size(); i ++)
        if (R[q][allowed[i]])
            sz += (1 << i);
    q++;

    while (q < R.size()){
        for (int x : allowed)
            res.push_back(R[q][x]);
        q++;
    }

    while (res.size() > sz)
        res.pop_back();

    return res;
}

Compilation message

message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:31:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (int j = 1; j < allowed.size(); j ++){
      |                         ~~^~~~~~~~~~~~~~~~
message.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < allowed.size(); i ++){
      |                     ~~^~~~~~~~~~~~~~~~
message.cpp:46:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     while (p < M.size()){
      |            ~~^~~~~~~~~~
message.cpp:47:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int j = 0; j < allowed.size(); j ++){
      |                         ~~^~~~~~~~~~~~~~~~
message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:75:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         for (int j = 1; j < allowed.size(); j ++){
      |                         ~~^~~~~~~~~~~~~~~~
message.cpp:83:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for (int i = 0; i < allowed.size(); i ++)
      |                     ~~^~~~~~~~~~~~~~~~
message.cpp:88:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     while (q < R.size()){
      |            ~~^~~~~~~~~~
message.cpp:94:23: warning: comparison of integer expressions of different signedness: 'std::vector<bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   94 |     while (res.size() > sz)
      |            ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 656 KB Used 36 days
# Verdict Execution time Memory Grader output
1 Correct 1503 ms 1088 KB Used 36 days
2 Correct 1511 ms 844 KB Used 36 days
3 Correct 1499 ms 832 KB Used 36 days
4 Correct 1432 ms 840 KB Used 36 days
5 Correct 1061 ms 840 KB Used 36 days
6 Correct 783 ms 844 KB Used 36 days
7 Correct 917 ms 928 KB Used 36 days
# Verdict Execution time Memory Grader output
1 Correct 2 ms 656 KB Used 36 days
2 Correct 1503 ms 1088 KB Used 36 days
3 Correct 1511 ms 844 KB Used 36 days
4 Correct 1499 ms 832 KB Used 36 days
5 Correct 1432 ms 840 KB Used 36 days
6 Correct 1061 ms 840 KB Used 36 days
7 Correct 783 ms 844 KB Used 36 days
8 Correct 917 ms 928 KB Used 36 days
9 Partially correct 2768 ms 1080 KB Used 71 days
10 Partially correct 1882 ms 848 KB Used 70 days
11 Partially correct 2779 ms 844 KB Used 71 days
12 Partially correct 2870 ms 860 KB Used 71 days
13 Partially correct 2730 ms 844 KB Used 70 days
14 Partially correct 2043 ms 844 KB Used 71 days
15 Partially correct 1527 ms 848 KB Used 71 days
16 Partially correct 1962 ms 844 KB Used 71 days
17 Partially correct 1990 ms 920 KB Used 70 days
18 Correct 1453 ms 844 KB Used 36 days
19 Correct 1389 ms 840 KB Used 36 days
20 Correct 1482 ms 832 KB Used 36 days
21 Correct 1459 ms 844 KB Used 36 days
22 Correct 1414 ms 844 KB Used 39 days
23 Correct 1658 ms 852 KB Used 45 days
24 Correct 1924 ms 848 KB Used 51 days
25 Correct 2130 ms 1080 KB Used 57 days
26 Correct 2412 ms 844 KB Used 64 days
27 Partially correct 2630 ms 848 KB Used 70 days
28 Partially correct 2844 ms 856 KB Used 71 days