QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50669#4912. WereYouLastQingyu100 ✓6354ms4864kbC++231.4kb2022-09-28 15:18:542022-09-28 15:18:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-28 15:18:56]
  • 评测
  • 测评结果:100
  • 用时:6354ms
  • 内存:4864kb
  • [2022-09-28 15:18:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bool query(int);
void modify(int,bool); 
const int
a0[18] = {3,0,0,17,3,3,3,3,3,3,3,3,3,3,3,3,3,16},
a1[18] = {3,0,1,17,2,4,5,6,7,8,9,10,11,12,13,14,15,16};
const int
b0[22] = {3,0,0,21,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,20},
b1[22] = {3,0,1,21,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
const int
c0[28] = {3,0,0,27,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,26},
c1[28] = {3,0,1,27,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26};
inline int getpos(){
	int i,r = 0;
	for (i = 1; i <= 5; ++i) r += query(i + 100) ? (1 << (i-1)) : (0);
	return r;
}
inline void setpos(int t){
	for (int i = 1; i <= 5; ++i) modify(i + 100,t >> (i-1) & 1); 
}
bool WereYouLast(int n, int m){
	if (n == (1 << 16)){
		int x = getpos();
		int st = query(x + 1); modify(x+1,st ^ 1);
		x = st ? a1[x] : a0[x];
		if (x == 1) return 1;
		setpos(x);
		return 0;
	}
	if (n == (1 << 20)){
		int x = getpos();
		int st = query(x + 1); modify(x+1,st ^ 1);
		x = st ? b1[x] : b0[x];
		if (x == 1) return 1;
		setpos(x);
		return 0;
	}
	if (n == (1 << 26)){
		int x = getpos();
		int st = query(x + 1); modify(x+1,st ^ 1);
		x = st ? c1[x] : c0[x];
		if (x == 1) return 1;
		setpos(x);
		return 0;
	}
	int l = 1; while ((1 << l) < n) ++l;
	for (int i = 1; i <= l; ++i){
		if (!query(i)){ modify(i,1); return 0; }
		modify(i,0); 
	}
	return 1;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 2ms
memory: 3652kb

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: 4852kb

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: 101ms
memory: 4812kb

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: 6354ms
memory: 4864kb

input:

67108864 100000

output:

12345876 6 6

result:

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