Submission #1335167

#TimeUsernameProblemLanguageResultExecution timeMemory
1335167minh30082008메시지 (IOI24_message)C++20
0 / 100
133 ms824 KiB
#include "message.h"
#include<bits/stdc++.h>
#define fi first
#define se second
#define FOR(i, k, n) for(int i = k; i <= n; i++)
#define FOR1(i, k, n) for(int i = k; i >= n; i--)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define vll vector<ll>
#define pll pair<ll, ll>
#define re return 0
#define mii map<int, int>
#define input "wtf.inp"
#define output "wtf.out"
#define rf 	freopen(input, "r", stdin); freopen(output, "w", stdout)
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int base = 65537;
const int base1 = 31;
const int SZ = 320;
const ll INF = 1e18;
const long double EPS = 1e-9;
void add(int &a, int b) 
{
	a += b; 
	if(a >= mod) a -= mod; 
	if(a < 0) a += mod; 
}
int a[20] = {182938127, 192831722, 94812843, 192402, 1829381, 1528374653, 81741, 1928467562, 19238123, 192312, 12391, 1458275938, 8192842, 91282321, 91828312, 918283762, 741829385, 8192834, 812, 3008};

void send_message(vector<bool> M, vector<bool> C) {
	vector<bool> send;
	FOR(i, 0, 19)
	{
		send.clear();
		FOR(bit, 0, 30)
			if((a[i] >> bit) & 1)
				send.pb(1);
			else
				send.pb(0);
		send_packet(send);
	}
	vi vt;
	FOR(i, 0, 30)
		if(C[i] == 0)
			vt.pb(i);
	int S = M.size();
	FOR(i, 0, 30)
		send[i] = 0;
	FOR(i, 0, 15)
		if((S >> i) & 1)
		{
			send[vt[i]] = 1;
		}
	send_packet(send);
	int res = S / 16;
	FOR(i, 0, res - 1)
	{
		int l = i * 16;
		int r = l + 15;
		FOR(j, 0, 30)
			send[j] = 0;
		FOR(j, l, r)
		{
			if(M[j] == 1)
				send[vt[j - l]] = 1;
		}
		send_packet(send);
	}
	if(S % 16)
	{
		int l = res * 16;
		int r = S - 1;
		FOR(j, 0, 30)
			send[j] = 0;
		FOR(j, l, r)
			if(M[j] == 1)
				send[vt[j - l]] = 1;
		send_packet(send);
	}
	return;
}

bool vis[35];
vector<bool> receive_message(vector<vector<bool>> R) {
	FOR(i, 0, 30)
		vis[i] = 1;
	FOR(i, 0, 19)
	{
		FOR(bit, 0, 30)
			if((R[i][bit] != ((a[i] >> bit) & 1)))
				vis[bit] = 0;
	}
	vi vt;
	FOR(i, 0, 30)
		if(vis[i])
			vt.pb(i);
	assert(vt.size() == 16);
	vector<bool> ans;
	int S = 0;
	FOR(i, 0, 15)
		if(R[20][vt[i]] == 1)
			S += (1 << i);
	int res = S / 16;
	FOR(i, 0, res - 1)
	{
		FOR(j, 0, 15)
			ans.pb(R[21 + i][vt[j]]);
	}
	int id = 21 + res;
	if(S % 16)
	{
		int d = S % 16;
		d--;
		FOR(j, 0, d)
			ans.pb(R[id][vt[j]]);
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...