QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#560122#9237. MessagesynonymCompile Error//C++172.5kb2024-09-12 13:00:262024-09-12 13:00:26

Judging History

你现在查看的是最新测评结果

  • [2024-09-12 13:00:26]
  • 评测
  • [2024-09-12 13:00:26]
  • 提交

answer

#include "bits/stdc++.h"
#include "message.h"

using namespace std;
#define int long long
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()

const int L = 31;

vector<vector<bool>> kk;

void send_packet(vector<bool> s) {
	kk.push_back(s);
}

void send_message(vector<bool> M, vector<bool> C) {
	vector<int> pos;
	for (int i=0; i<L; i++) {if (!C[i]) pos.push_back(i);}
	vector<int> dist;
	for (int i=0; i<sz(pos); i++) {
		dist.push_back((L+pos[(i+1)%sz(pos)]-pos[i]-1)%L);
	}
	vector<vector<int>> mess(100,vector<int>(L,-1));
	for (int i=0; i<sz(pos); i++) {
		for (int j=0; j<dist[i]; j++) {
			mess[j][pos[i]]=1;
		}
		mess[dist[i]][pos[i]]=0;
	}
	vector<array<int,2>> ava;
	for (int i=0; i<100; i++) {
		for (int j=0; j<sz(pos); j++) {
			if (mess[i][pos[j]]==-1) {
				ava.push_back({i,pos[j]});
			}
		}
	}
	sort(all(ava)); int cp = 0;
	int len = sz(M)-1;
	for (int i=0; i<10; i++) {
		auto [a,b] = ava[cp++];
//		cout<<a<<" "<<b<<" "<<(1<<i)<<" "<<((1<<i)&len)<<endl;
		mess[a][b] = ((1<<i)&len)?1:0;
	}
	for (auto i : M) {
		auto [a,b] = ava[cp++];
		mess[a][b] = i?1:0;
	}
	for (auto i : mess) {
		int bad=1;
		for (int j:i) {
			if (j!=-1) bad=0;
		}
		if (bad) break;
		vector<bool> packet;
		for (int j:i) {
			packet.push_back(j==1);
		}
		send_packet(packet);
	}
}

vector<bool> receive_message(vector<vector<bool>> R) {
	vector<int> nx(L,1);
	for (int i=0; i<L; i++) {
		for (auto m : R) {
			if (!m[i]) break;
			nx[i]++;
		}
	}
	vector<int> pos;
	for (int i=0; i<L; i++) {
		int cyc = 1;
		int cp = (i+nx[i])%L;
		while (cp != i) {
			cp = (cp+nx[cp])%L;
			cyc++;
			if (cyc==100) break;
		}
		if (cyc==16) pos.push_back(i);
	}
	vector<array<int,2>> ava;
	for (int i : pos) {
		for (int j=nx[i]; j<sz(R); j++) {
			ava.push_back({j,i});
		}
	}
	sort(all(ava));
	int len=1;
	int cp = 0;
	for (int i=0; i<10; i++) {
		auto [a,b] = ava[cp++];
		bool x = R[a][b];
		if (x) len += (1<<i);
	}
	vector<bool> ans;
	for (int i=0; i<len; i++) {
		auto [a,b] = ava[cp++];
		bool x = R[a][b];
		ans.push_back(x);
	}
//	cout<<len<<endl;
	return ans;
}
/*
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	vector<bool> msg(1024,0);
	vector<bool> ctrl;
	for (int i=0; i<15; i++) {
		ctrl.push_back(1);
	}
	ctrl.resize(31);
	send_message(msg,ctrl);
/*	for (auto i : kk) {
		for (auto j:i) cout<<j;
		cout<<endl;
	}
	auto x = receive_message(kk);
//	cout<<sz(x)<<endl;
	for (auto i : x) cout<<i;
	return 0;
}
*/

详细

answer.code:13:6: error: ambiguating new declaration of ‘void send_packet(std::vector<bool>)’
   13 | void send_packet(vector<bool> s) {
      |      ^~~~~~~~~~~
In file included from answer.code:2:
message.h:5:19: note: old declaration ‘std::vector<bool> send_packet(std::vector<bool>)’
    5 | std::vector<bool> send_packet(std::vector<bool> A);
      |                   ^~~~~~~~~~~