QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#448933#4912. WereYouLastCSQ29 257ms5132kbC++141.1kb2024-06-20 13:20:082024-06-20 13:20:08

Judging History

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

  • [2024-06-20 13:20:08]
  • 评测
  • 测评结果:29
  • 用时:257ms
  • 内存:5132kb
  • [2024-06-20 13:20:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bool query(int);
void modify(int,bool);
bool WereYouLast(int N, int m){
	if(N==1024){
		int c = 0;
		for(int i=0;i<10;i++){
			if(query(i+1))c+=(1<<i);
		}
		c++;
		if(c == 1024)return 1;
		for(int i=0;i<10;i++){
			if(c&(1<<i))modify(i+1,1);
			else modify(i+1,0);
		}
	}else{
		int n = 0;
		for(int i=0;i<=26;i++){
			if((1<<i)<=N)n = i;
		}
		//cout<<n<<'\n';
		int mx = query(n+1);
		int flip = query(n+2);
		if(mx){
			modify(n+1,0);
			modify(n+2,flip^1);
			int c = 0;
			for(int i=0;i<n/2;i++){
				if(query(i+n/2+1))c += (1<<i);
			}
			c++;
			if(c == (1<<(n/2)))return 1;
			for(int i=0;i<n/2;i++){
				if(c&(1<<i))modify(i+n/2+1,1);
				else modify(i+n/2+1,0);
			}
		}else{
			int c = 0;
		    for(int i=0;i<n/2;i++){
				if(query(i+1))c += (1<<i);
			}
			if(flip)c ^= (1<<(n/2))-1;
			c++;
			//cout<<c<<'\n';
			for(int i=0;i<n/2;i++){
				if(c&(1<<i))modify(i+1,flip^1);
				else modify(i+1,flip);
			}
			if(c == (1<<(n/2))-1)modify(n+1,1);
		}
	}
	return 0;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

1024 10

output:

12345876 10 10

result:

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

Subtask #2:

score: 10
Acceptable Answer

Test #2:

score: 10
Acceptable Answer
time: 12ms
memory: 5048kb

input:

65536 100000

output:

12345876 10 10

result:

points 0.50 Correct Answer.
C1 = 10.
C2 = 10.

Subtask #3:

score: 9
Acceptable Answer

Test #3:

score: 9
Acceptable Answer
time: 257ms
memory: 5132kb

input:

1048576 100000

output:

12345876 12 12

result:

points 0.30 Correct Answer.
C1 = 12.
C2 = 12.

Subtask #4:

score: 0
Time Limit Exceeded

Test #4:

score: 0
Time Limit Exceeded

input:

67108864 100000

output:


result: