QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601872#9237. MessagePittow100 ✓191ms4080kbC++171.5kb2024-09-30 15:07:102024-09-30 15:07:10

Judging History

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

  • [2024-09-30 15:07:10]
  • 评测
  • 测评结果:100
  • 用时:191ms
  • 内存:4080kb
  • [2024-09-30 15:07:10]
  • 提交

answer

#include "message.h"
typedef std::vector<bool> arr;
typedef std::vector<arr> arr2;

bool d[31],e[31],f[31];//d:decode e,f:encode
int r[31],id;//point
int encode(int p){
	if(r[p]!=-1)return r[p];
	int l=(p+1)%31;
	while(l!=p&&!d[l])l=encode(l);
	if(l==p){id=p;return -1;}
	(++l)%=31;
	return r[p]=l;
}
int rt,flag;
int decode(int p){//return end
	if(!d[p]){
		if(p!=rt)++flag;
		return p;
	}
	d[p]=0;
	int l=(p+1)%31;
	if(!f[p])l=decode(l);
	if(l==p){
		id=p;
		if(l==rt)--flag;
		else ++flag;
		return p;
	}
	(++l)%=31;
	if(!e[p])return decode(l);
	return l;
}
bool check(int p){
	int i,j;
	for(i=0;i<31;++i)d[i]=1;
	flag=1;
	rt=p;
	decode(p);
	for(i=j=0;i<31;++i)if(!d[i])++j;
	if(j!=16)return 1;
	return flag;
}
bool u[1024];
void send_message(arr M,arr C){
	int s=M.size(),i,j;
	arr A(31);
	for(i=0;i<31;++i)A[i]=C[(i+1)%31];
	send_packet(A);
	for(i=0;i<31;++i)r[i]=-1,d[i]=C[i];
	for(i=0;i<31;++i)if(!d[i]&&r[i]==-1)encode(i);
	for(i=0;i<31;++i)if(r[i]!=-1)A[i]=C[r[i]];
	A[id]=M[s-1];
	M[s-1]=0;
	for(i=0;i<s;++i)u[i]=M[i];
	while(i<1024)u[i++]=1;
	send_packet(A);
	for(i=0;i<s;){
		for(j=0;j<31;++j)if(!C[j])A[j]=u[i++];
		send_packet(A);
	}
}
arr receive_message(arr2 R){
	int s=R.size(),i,j,k;
	for(i=0;i<31;++i)e[i]=R[1][i],f[i]=R[0][i];
	for(i=j=0;i<31;++i)if(!check(i))++j;
	for(i=0;check(i);++i);
	for(i=2,k=0;i<s;++i)
	for(j=0;j<31;++j)if(!d[j])u[k++]=R[i][j];
	for(s=(s-2)*16;u[s-1];--s);
	arr A(s);
	for(i=0;i<s;++i)A[i]=u[i];
	A[s-1]=e[id];
	return A;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 17ms
memory: 3724kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #2:

score: 10
Accepted
time: 24ms
memory: 4000kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #3:

score: 10
Accepted
time: 19ms
memory: 4080kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #4:

score: 10
Accepted
time: 20ms
memory: 3808kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #5:

score: 10
Accepted
time: 9ms
memory: 4004kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #6:

score: 10
Accepted
time: 13ms
memory: 3764kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #7:

score: 10
Accepted
time: 0ms
memory: 3804kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Subtask #2:

score: 90
Accepted

Test #8:

score: 90
Accepted
time: 152ms
memory: 4016kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #9:

score: 90
Accepted
time: 116ms
memory: 3752kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #10:

score: 90
Accepted
time: 171ms
memory: 3816kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #11:

score: 90
Accepted
time: 191ms
memory: 3968kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #12:

score: 90
Accepted
time: 148ms
memory: 3756kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #13:

score: 90
Accepted
time: 77ms
memory: 3792kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #14:

score: 90
Accepted
time: 64ms
memory: 3736kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #15:

score: 90
Accepted
time: 168ms
memory: 3988kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #16:

score: 90
Accepted
time: 77ms
memory: 3812kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #17:

score: 90
Accepted
time: 18ms
memory: 4008kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #18:

score: 90
Accepted
time: 41ms
memory: 3792kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #19:

score: 90
Accepted
time: 71ms
memory: 3792kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #20:

score: 90
Accepted
time: 56ms
memory: 3760kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #21:

score: 90
Accepted
time: 73ms
memory: 3740kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #22:

score: 90
Accepted
time: 94ms
memory: 4080kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #23:

score: 90
Accepted
time: 111ms
memory: 4000kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #24:

score: 90
Accepted
time: 111ms
memory: 3968kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #25:

score: 90
Accepted
time: 145ms
memory: 3808kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #26:

score: 90
Accepted
time: 176ms
memory: 3972kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Test #27:

score: 90
Accepted
time: 183ms
memory: 3972kb

Manager to Aisha


Aisha to Manager


Manager to Basma


Basma to Manager


Manager to Checker

1

result:

points 1.0

Extra Test:

score: 0
Extra Test Passed