QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#150641#4912. WereYouLastzhouhuanyi88 4833ms5036kbC++143.4kb2023-08-25 22:49:242023-08-25 22:49:25

Judging History

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

  • [2023-08-25 22:49:25]
  • 评测
  • 测评结果:88
  • 用时:4833ms
  • 内存:5036kb
  • [2023-08-25 22:49:24]
  • 提交

answer

#include<bits/stdc++.h>
#define N 7
using namespace std;
bool query(int);
void modify(int,bool);
int a[N+1]={0,5,4,3,2,2},b[N+1]={0,13,4,3,2,2},b2[N+1]={0,3,3,2,1},c[N+1]={0,7,6,5,4,3,1},d[N+1],d2[N+1];
bool WereYouLast(int n,int m)
{
	if (n==(1<<10))
	{
		for (int i=1;i<=10;++i)
			if (!query(i))
			{
				for (int j=1;j<=i-1;++j) modify(j,0);
				modify(i,1);
				return 0;
			}
		return 1;
	}
	else if (n==(1<<16))
	{
		int res=4;
		bool op;
		for (int i=1;i<=5;++i)
		{
			if (i==5||!query(i))
			{
				for (int j=1;j<=a[i];++j) d[j]=query(res+j);
				op=1;
				for (int j=1;j<=a[i];++j) op&=d[j];
				if (op) return 1;
				for (int j=1;j<=a[i];++j)
					if (!d[j])
					{
						d[j]=1,modify(res+j,1);
						for (int k=1;k<=j-1;++k) d[k]=0,modify(res+k,0);
						break;
					}
				op=1;
				for (int j=1;j<=a[i];++j) op&=d[j];
				if (i!=5&&op)
				{
					for (int j=1;j<=a[i];++j) modify(res+j,0);
					modify(i,1);
				}
				for (int j=1;j<=i-1;++j) modify(j,0);
				return 0;
			}
			res+=a[i];
		}
	}
	else if (n==(1<<20))
	{
		int res=4,res2;
		bool op,op2;
		for (int i=1;i<=5;++i)
		{
			if (i==5||!query(i))
			{
				if (i==1)
				{
					res2=res+3,op=0;
					for (int j=1;j<=4;++j)
					{
						if (j==4||!query(res+j))
						{
							for (int k=1;k<=b2[j];++k) d2[k]=query(res2+k);
							if (j==1&&!query(res+b[i])) d2[1]=1,modify(res2+1,1),modify(res+b[i],1);
							op2=1;
							for (int k=1;k<=b2[j];++k) op2&=d2[k];
							if (op2)
							{
								op=1;
								break;
							}
							for (int k=1;k<=b2[j];++k)
								if (!d2[k])
								{
									d2[k]=1,modify(res2+k,1);
									for (int t=1;t<=k-1;++t) d2[t]=0,modify(res2+t,0);
									break;
								}
							op2=1;
							for (int k=1;k<=b2[j];++k) op2&=d2[k];
							if (j!=4&&op2)
							{
								for (int k=1;k<=b2[j];++k) modify(res2+k,0);
								modify(res+j,1);
							}
							for (int k=1;k<=j-1;++k) modify(res+k,0);
							break;
						}
						res2+=b2[j];
					}
					if (op)
					{
						for (int j=1;j<=3;++j) modify(res+j,0);
						for (int j=1;j<=b2[4];++j) modify(res2+j,0);
						modify(res+b[i],0),modify(i,1);
					}
					for (int j=1;j<=i-1;++j) modify(j,0);
				}
				else
				{
					for (int j=1;j<=b[i];++j) d[j]=query(res+j);
					op=1;
					for (int j=1;j<=b[i];++j) op&=d[j];
					if (op) return 1;
					for (int j=1;j<=b[i];++j)
						if (!d[j])
						{
							d[j]=1,modify(res+j,1);
							for (int k=1;k<=j-1;++k) d[k]=0,modify(res+k,0);
							break;
						}
					op=1;
					for (int j=1;j<=b[i];++j) op&=d[j];
					if (i!=5&&op)
					{
						for (int j=1;j<=b[i];++j) modify(res+j,0);
						modify(i,1);
					}
					for (int j=1;j<=i-1;++j) modify(j,0);
				}
				return 0;
			}
			res+=b[i];
		}
	}
	else if (n==(1<<26))
	{
		int res=5;
		bool op;
		for (int i=1;i<=6;++i)
		{
			if (i==6||!query(i))
			{
				for (int j=1;j<=c[i];++j) d[j]=query(res+j);
				op=1;
				for (int j=1;j<=c[i];++j) op&=d[j];
				if (op) return 1;
				for (int j=1;j<=c[i];++j)
					if (!d[j])
					{
						d[j]=1,modify(res+j,1);
						for (int k=1;k<=j-1;++k) d[k]=0,modify(res+k,0);
						break;
					}
				op=1;
				for (int j=1;j<=c[i];++j) op&=d[j];
				if (i!=6&&op)
				{
					for (int j=1;j<=c[i];++j) modify(res+j,0);
					modify(i,1);
				}
				for (int j=1;j<=i-1;++j) modify(j,0);
				return 0;
			}
			res+=c[i];
		}
	}
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 1ms
memory: 3736kb

input:

1024 10

output:

12345876 10 10

result:

ok Correct Answer.
C1 = 10.
C2 = 10.

Subtask #2:

score: 20
Accepted

Test #2:

score: 20
Accepted
time: 1ms
memory: 5036kb

input:

65536 100000

output:

12345876 6 6

result:

ok Correct Answer.
C1 = 6.
C2 = 6.

Subtask #3:

score: 30
Accepted

Test #3:

score: 30
Accepted
time: 64ms
memory: 4912kb

input:

1048576 100000

output:

12345876 6 6

result:

ok Correct Answer.
C1 = 6.
C2 = 6.

Subtask #4:

score: 28
Acceptable Answer

Test #4:

score: 28
Acceptable Answer
time: 4833ms
memory: 4960kb

input:

67108864 100000

output:

12345876 8 8

result:

points 0.70 Correct Answer.
C1 = 8.
C2 = 8.