답안 #1103076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103076 2024-10-19T23:07:05 Z aaaaaarroz 메시지 (IOI24_message) C++17
10 / 100
1526 ms 920 KB
#include <bits/stdc++.h>
using namespace std;
vector<bool> send_packet(vector<bool> A);
void send_message(vector<bool> M, vector<bool> C){
	for(int i=0;i<25;i++){
		vector<bool>enviar(31,!C[i]);
		send_packet(enviar);
	}
	vector<bool>enviar(31);
	int pos=0;
	int cnt=0;
	while(pos<31){
		if(cnt==6){
			break;
		}
		else{
			if(!C[pos]){
				enviar[pos]=!C[cnt+25];
				cnt++;
			}
			else{
				enviar[pos]=0;
			}
		}
		pos++;
	}
	int cantidad=M.size();
	int bit=0;
	for(int i=pos;i<31;i++){
		if(!C[i]){
			enviar[i]=cantidad&(1<<bit);
			bit++;
		}
	}
	send_packet(enviar);
	vector<bool>envio;
	pos=0;
	while(pos<M.size()){
		if(C[envio.size()]==0){
			envio.push_back(M[pos]);
			pos++;
		}
		else{
			envio.push_back(0);
		}
		if(envio.size()==31){
			send_packet(envio);
			envio.clear();
		}
	}
	while(envio.size()<31){
		envio.push_back(false);
		if(envio.size()==31){
			send_packet(envio);
			break;
		}
	}
}
vector<bool> receive_message(vector<vector<bool>> R){
	vector<bool>funciona(31,false);
	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;
	int cnt=0;
	for(int i=0;i<31;i++){
		if(cnt<6){
			if(funciona[i]){
				funciona[cnt+25]=R[25][i];
				cnt++;
			}
		}
		else{
			if(funciona[i]){
				if(R[25][i]){
					largo+=(1<<bit_real);
				}
				bit_real++;
			}
		}
	}
	vector<bool>sec;
	for(int i=26;i<R.size();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:38:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  while(pos<M.size()){
      |        ~~~^~~~~~~~~
message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:92:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |  for(int i=26;i<R.size();i++){
      |               ~^~~~~~~~~
message.cpp:99:18: warning: comparison of integer expressions of different signedness: 'std::vector<bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   99 |  while(sec.size()>largo){
      |        ~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 656 KB Used 27 days
# 결과 실행 시간 메모리 Grader output
1 Correct 535 ms 920 KB Used 31 days
2 Correct 506 ms 824 KB Used 30 days
3 Correct 534 ms 832 KB Used 31 days
4 Correct 574 ms 832 KB Used 30 days
5 Correct 401 ms 836 KB Used 31 days
6 Correct 294 ms 836 KB Used 30 days
7 Correct 309 ms 828 KB Used 30 days
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 656 KB Used 27 days
2 Correct 535 ms 920 KB Used 31 days
3 Correct 506 ms 824 KB Used 30 days
4 Correct 534 ms 832 KB Used 31 days
5 Correct 574 ms 832 KB Used 30 days
6 Correct 401 ms 836 KB Used 31 days
7 Correct 294 ms 836 KB Used 30 days
8 Correct 309 ms 828 KB Used 30 days
9 Incorrect 1526 ms 420 KB decoded message is incorrect
10 Halted 0 ms 0 KB -