답안 #1099819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099819 2024-10-12T05:24:08 Z model_code 메시지 (IOI24_message) C++17
29.3175 / 100
1377 ms 1068 KB
// partially_correct/badawy_m_32.cpp

#include "message.h"

#include <iostream>
#include <vector>
#include <algorithm>

const int LG=4, POS=31;

void send_message(std::vector<bool> message, std::vector<bool> positions) {
    for (int i=0;i<POS;i++) {
        std::vector<bool> bits(POS);
        for (int j=0; j<POS; j++) bits[j] = positions[i];
        send_packet(bits);
    }
    std::vector<int> needed, mine;
    for(int i=0;i<POS;i++)
        if(positions[i]==0) mine.push_back(i);
    int sz=(message.size()+LG);
    int rem=16 - (sz%16);
    rem%=16;
    for(int i=0;i<LG;i++)
    {
        needed.push_back(rem%2);
        rem/=2;
    }
    for(int i=0;i<message.size();i++) needed.push_back(message[i]);
    rem=16 - (sz%16);
    rem%=16;
    for(int i=0;i<rem;i++) needed.push_back(0);
    for(int round=0;round<needed.size()/16;round++)
    {
        std::vector<bool> bits(POS);
        for(int j=0;j<16;j++)
            bits[mine[j]]=needed[round*16+j];
        send_packet(bits);
    }
}

std::vector<bool> receive_message(std::vector<std::vector<bool>> received_bits) {
    std::vector<bool> message;
    std::vector<int> mine;
    for(int i=0;i<31;i++)
    {
        sort(received_bits[i].begin(), received_bits[i].end());
        if(received_bits[i][15]==0) mine.push_back(i);
    }
    std::vector<bool> received;
    for(int i=31;i<received_bits.size();i++)
    {
        for(int j:mine) received.push_back(received_bits[i][j]);
    }
    int rem=0;
    for(int i=LG-1;i>=0;i--)
    {
        rem*=2; rem+=received[i];
    }
    for(int i=LG;i<received.size()-rem;i++)
        message.push_back(received[i]);
    return message;
}

Compilation message

message.cpp: In function 'void send_message(std::vector<bool>, std::vector<bool>)':
message.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<message.size();i++) needed.push_back(message[i]);
      |                 ~^~~~~~~~~~~~~~~
message.cpp:32:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int round=0;round<needed.size()/16;round++)
      |                     ~~~~~^~~~~~~~~~~~~~~~~
message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:50:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=31;i<received_bits.size();i++)
      |                  ~^~~~~~~~~~~~~~~~~~~~~
message.cpp:59:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=LG;i<received.size()-rem;i++)
      |                  ~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 752 KB Used 32 days
# 결과 실행 시간 메모리 Grader output
1 Correct 514 ms 804 KB Used 36 days
2 Correct 504 ms 800 KB Used 36 days
3 Correct 529 ms 804 KB Used 36 days
4 Correct 460 ms 808 KB Used 35 days
5 Correct 387 ms 812 KB Used 36 days
6 Correct 270 ms 1052 KB Used 36 days
7 Correct 279 ms 796 KB Used 36 days
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 752 KB Used 32 days
2 Correct 514 ms 804 KB Used 36 days
3 Correct 504 ms 800 KB Used 36 days
4 Correct 529 ms 804 KB Used 36 days
5 Correct 460 ms 808 KB Used 35 days
6 Correct 387 ms 812 KB Used 36 days
7 Correct 270 ms 1052 KB Used 36 days
8 Correct 279 ms 796 KB Used 36 days
9 Partially correct 1377 ms 848 KB Used 96 days
10 Partially correct 937 ms 840 KB Used 95 days
11 Partially correct 1288 ms 844 KB Used 96 days
12 Partially correct 1231 ms 828 KB Used 95 days
13 Partially correct 1322 ms 832 KB Used 95 days
14 Partially correct 923 ms 1068 KB Used 96 days
15 Partially correct 696 ms 848 KB Used 96 days
16 Partially correct 949 ms 840 KB Used 96 days
17 Partially correct 876 ms 832 KB Used 95 days
18 Correct 476 ms 796 KB Used 38 days
19 Correct 540 ms 800 KB Used 44 days
20 Correct 690 ms 824 KB Used 50 days
21 Correct 736 ms 804 KB Used 57 days
22 Correct 842 ms 832 KB Used 63 days
23 Partially correct 869 ms 832 KB Used 69 days
24 Partially correct 954 ms 820 KB Used 75 days
25 Partially correct 1153 ms 840 KB Used 82 days
26 Partially correct 1128 ms 832 KB Used 88 days
27 Partially correct 1267 ms 812 KB Used 94 days
28 Partially correct 1265 ms 972 KB Used 96 days