Submission #1103084

# Submission time Handle Problem Language Result Execution time Memory
1103084 2024-10-19T23:30:46 Z aaaaaarroz Message (IOI24_message) C++17
0 / 100
527 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){
	for(int i=0;i<24;i++){
		vector<bool>enviar(31,!C[i]);
		send_packet(enviar);
	}
	vector<bool>enviar(31,false);
	int cnt=0;
	for(int i=0;i<31;i++){
		if(cnt>=7){
			break;
		}
		if(!C[i]){
			enviar[i]=(!C[i]);
			cnt++;
		}
	}
	send_packet(enviar);
	enviar.resize(31,false);
	int bit=0;
	for(int i=0;i<31;i++){
		if(C[i]){
			continue;
		}
		if((1<<bit)&(M.size())){
			enviar[i]=1;
		}
	}
	send_packet(enviar);
	vector<bool>envio;
	int 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<24;i++){
		int votos=0;
		for(int j=0;j<31;j++){
			if(R[i][j]){
				votos++;
			}
		}
		if(votos>15){
			funciona[i]=true;
		}
	}
	int cnt=0;
	for(int i=0;i<31;i++){
		if(cnt>=7){
			break;
		}
		if(funciona[i]){
			funciona[24+cnt]=R[24][i];
			cnt++;
		}
	}
	int bit=0;
	int largo=0;
	for(int i=0;i<31;i++){
		if(!funciona[i]){
			continue;
		}
		if(R[25][i]){
			largo+=(1<<bit);
		}
		bit++;
	}
	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:34:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  while(pos<M.size()){
      |        ~~~^~~~~~~~~
message.cpp: In function 'std::vector<bool> receive_message(std::vector<std::vector<bool> >)':
message.cpp:90:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |  for(int i=26;i<R.size();i++){
      |               ~^~~~~~~~~
message.cpp:97:18: warning: comparison of integer expressions of different signedness: 'std::vector<bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   97 |  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 527 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 -