QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#491374#4912. WereYouLastlifan100 ✓5468ms5064kbC++14812b2024-07-25 19:08:102024-07-25 19:08:10

Judging History

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

  • [2024-07-25 19:08:10]
  • 评测
  • 测评结果:100
  • 用时:5468ms
  • 内存:5064kb
  • [2024-07-25 19:08:10]
  • 提交

answer

// 
#include<bits/stdc++.h>
using namespace std;
bool query(int);
void modify(int,bool);
bool WereYouLast(int n,int m){
	if(n==1024||m==10){
		int x=0;
		for(int i=1;i<=10;i++)x=x*2+query(i);
//		cerr<<x<<' '<<n<<endl;
		if(x==n-1)return 1;
		x++;
		for(int i=10;i>=1;i--)modify(i,x%2),x>>=1;
		return 0;
	}
	else{
		int x=0;
		for(int i=1;i<=5;i++){
			x=x*2+query(i);
		}
		int yy=0;
		int nn=n;
		while(nn)yy++,nn>>=1;
		yy--;
		if(x==yy)return 1;
		else if(x==yy-1){
			nn=yy;
			for(int i=5;i>=1;i--){
				modify(i,nn%2);
				nn>>=1;
			}
			return 0;
		}
		else{
			int op=query(100+x);
			if(op){
				modify(100+x,0);
				x++;
			}
			else{
				modify(100+x,1);
				x=0;
			}
			for(int i=5;i>=1;i--){
				modify(i,x%2);
				x>>=1;
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

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

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: 6ms
memory: 5064kb

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: 80ms
memory: 4984kb

input:

1048576 100000

output:

12345876 6 6

result:

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

Subtask #4:

score: 40
Accepted

Test #4:

score: 40
Accepted
time: 5468ms
memory: 4980kb

input:

67108864 100000

output:

12345876 6 6

result:

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