QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#308284#5018. nthHarry271820 31ms26696kbC++142.8kb2024-01-19 20:31:192024-01-19 20:31:19

Judging History

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

  • [2024-01-19 20:31:19]
  • 评测
  • 测评结果:0
  • 用时:31ms
  • 内存:26696kb
  • [2024-01-19 20:31:19]
  • 提交

answer

#include<bits/stdc++.h>
#include"nth.h"
using namespace std; 
namespace Alice
{
	int n=0,a[(1<<21)+5],l,r,dep,tmp[(1<<21)+5],c;
	void send()
	{
		int mid=(l+r)>>1;
		sendA((a[mid]>>dep)&1);
	}
	void initA(bitset<M> A,unsigned S,unsigned c)
	{
		for(int i=0;i<(1<<21);i++)if(A[i])a[++n]=i;
		int m=S-n;
		if(m>=c&&n>=c)n=c,c=0;
		else if(max(n,m)>=c)
		{
			if(n>=c)
			{
				for(int i=1;i<=n;i++)tmp[i]=a[i];
				int tot=0;
				for(int i=c-m;i<=c;i++)a[++tot]=tmp[i];
				n=tot;
			}
			else 
			{
				int tot=0;
				for(int i=1;i<=n;i++)tmp[i]=a[i];
				a[++tot]=0;
				for(int i=1;i<=n;i++)a[++tot]=tmp[i];
				n=tot;
			}
			c=1;
		}
		else
		{
			int tot=0;
			for(int i=1;i<=n;i++)tmp[i]=a[i];
			for(int i=c-m;i<=n;i++)a[++tot]=tmp[i];
			n=tot;c=0;
		}
		//for(int i=1;i<=n;i++)cout<<a[i]<<' ';cout<<'\n';
		l=1;r=n;dep=20;Alice::c=c;send();
	}
	void receiveA(bool x)
	{
		int mid=(l+r)>>1;
		int now=(a[mid]>>dep)&1;
		if(now<x)l=mid;
		else if(now>x)r=mid;
		else 
		{
			int val=(a[mid]>>dep)<<dep;
			for(int i=1;i<=n;i++)a[i]=max(a[i],val),a[i]=min(a[i],val+(1<<dep)-1);
			dep--;
		}
		if(l==r&&((now>x&&c==1)||(now<x&&c==0)))report(a[l]);
		if(dep==-1)report(a[l]);
		if(l==r-1)
		{
			for(int i=dep;i>=0;i--)sendA((a[l]>>i)&1);
			for(int i=dep;i>=0;i--)sendA((a[r]>>i)&1);
		}
		else send();
	}
}
namespace Bob
{	
	int n=0,b[(1<<21)+5],l,r,dep,tmp[(1<<21)+5],val[105],p,c,res[4];
	void send()
	{
		int mid=(l+r+1)>>1;
		sendB((b[mid]>>dep)&1);
	}
	void initB(std::bitset<M> B,unsigned S,unsigned c)
	{
		for(int i=0;i<(1<<21);i++)if(B[i])b[++n]=i;
		int m=S-n;
		if(m>=c&&n>=c)n=c,c=0;
		else if(max(n,m)>=c)
		{
			if(n>=c)
			{
				for(int i=1;i<=n;i++)tmp[i]=b[i];
				int tot=0;
				for(int i=c-m;i<=c;i++)b[++tot]=tmp[i];
				n=tot;
			}
			else 
			{
				int tot=0;
				for(int i=1;i<=n;i++)tmp[i]=b[i];
				b[++tot]=0;
				for(int i=1;i<=n;i++)b[++tot]=tmp[i];
				n=tot;
			}
			c=1;
		}
		else
		{
			int tot=0;
			for(int i=1;i<=n;i++)tmp[i]=b[i];
			for(int i=c-m;i<=n;i++)b[++tot]=tmp[i];
			n=tot;c=0;
		}
		//for(int i=1;i<=n;i++)cout<<b[i]<<'\n';
		l=1;r=n;dep=20;Bob::c=c;send();
	}
	void receiveB(bool x)
	{
		int mid=(l+r+1)>>1;
		int now=(b[mid]>>dep)&1;
		if(now<x)l=mid;
		else if(now>x)r=mid;
		else 
		{
			int val=(b[mid]>>dep)<<dep;
			for(int i=1;i<=n;i++)b[i]=max(b[i],val),b[i]=min(b[i],val+(1<<dep)-1);
			dep--;
		}
		if(l==r&&((now>x&&c==1)||(now<x&&c==0)))report(b[l]);
		if(dep==-1)report(b[l]);
		if(l==r-1&&dep==0)
		{
			val[p++]=x;
			if(p==2*dep)
			{
				res[0]=b[l];res[1]=b[r];
				for(int i=0;i<dep;i++)res[2]=res[2]<<1|val[i];
				for(int i=dep;i<2*dep;i++)res[3]=res[3]<<1|val[i];
				sort(res,res+4);
				if(c==0)report(res[1]);
				else report(res[2]);
			}
		}
		else send();
	}
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 100
Accepted
time: 31ms
memory: 25684kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

3196614622 1083345 2

result:

points 1.0 OK L = 2

Test #2:

score: 100
Accepted
time: 31ms
memory: 26696kb

input:

111111100101001001100100000000111110101000101001001100101010011110000110101011010000000001000111000001011011110101010111001101010000101001101011101001110011001001101111110100001111001001010000110000011011000101010010000000011010010111110000111011011100110000100101111000111111110001100110110111101001...

output:

4153393124 307591 7

result:

points 1.0 OK L = 7

Test #3:

score: 45
Acceptable Answer
time: 30ms
memory: 26440kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

1444424234 522975 198

result:

points 0.450 OK L = 198

Test #4:

score: 0
Wrong Answer
time: 31ms
memory: 25316kb

input:

001101001011011011110001100111001010010100110110111111100011101010001111110101110101110011111001110110111010001100100011010101011000000000001010010001011111110101111100000101000010101110100000110101010100100100010010110010010000001010010100110110100101111110010011011111011111110010100010001110110011...

output:

3619264599 1519398 52

result:

wrong answer Wrong Answer.