답안 #1099817

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099817 2024-10-12T05:23:45 Z model_code 메시지 (IOI24_message) C++17
28.3516 / 100
1359 ms 1240 KB
// partially_correct/badawy_m_33.cpp

#include "message.h"

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

const int LG=17, POS=31;
using namespace std;

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();
    for(int i=0;i<LG;i++)
    {
        needed.push_back(sz%2);
        sz/=2;
    }
    for(int i=0;i<message.size();i++) needed.push_back(message[i]);
    int rem=16-(needed.size()%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 len=0;
    for(int i=LG-1;i>=0;i--)
    {
        len*=2; len+=received[i];
    }
    for(int i=LG;i<LG+len;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:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<message.size();i++) needed.push_back(message[i]);
      |                 ~^~~~~~~~~~~~~~~
message.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     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:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=31;i<received_bits.size();i++)
      |                  ~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 664 KB Used 33 days
# 결과 실행 시간 메모리 Grader output
1 Correct 531 ms 812 KB Used 37 days
2 Correct 517 ms 816 KB Used 36 days
3 Correct 499 ms 1060 KB Used 37 days
4 Correct 457 ms 816 KB Used 36 days
5 Correct 382 ms 800 KB Used 37 days
6 Correct 276 ms 804 KB Used 36 days
7 Correct 350 ms 808 KB Used 37 days
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 664 KB Used 33 days
2 Correct 531 ms 812 KB Used 37 days
3 Correct 517 ms 816 KB Used 36 days
4 Correct 499 ms 1060 KB Used 37 days
5 Correct 457 ms 816 KB Used 36 days
6 Correct 382 ms 800 KB Used 37 days
7 Correct 276 ms 804 KB Used 36 days
8 Correct 350 ms 808 KB Used 37 days
9 Partially correct 1350 ms 844 KB Used 97 days
10 Partially correct 913 ms 1076 KB Used 96 days
11 Partially correct 1359 ms 1012 KB Used 97 days
12 Partially correct 1264 ms 924 KB Used 96 days
13 Partially correct 1263 ms 812 KB Used 96 days
14 Partially correct 851 ms 840 KB Used 97 days
15 Partially correct 648 ms 840 KB Used 97 days
16 Partially correct 882 ms 836 KB Used 96 days
17 Partially correct 916 ms 844 KB Used 96 days
18 Correct 535 ms 816 KB Used 39 days
19 Correct 618 ms 816 KB Used 45 days
20 Correct 660 ms 828 KB Used 51 days
21 Correct 802 ms 800 KB Used 58 days
22 Correct 821 ms 848 KB Used 64 days
23 Partially correct 922 ms 824 KB Used 70 days
24 Partially correct 915 ms 1240 KB Used 76 days
25 Partially correct 1041 ms 1064 KB Used 83 days
26 Partially correct 1260 ms 836 KB Used 89 days
27 Partially correct 1265 ms 840 KB Used 95 days
28 Partially correct 1281 ms 840 KB Used 97 days