QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#491772#4912. WereYouLastddxrS90 6423ms5036kbC++14920b2024-07-25 21:58:292024-07-25 21:58:30

Judging History

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

  • [2024-07-25 21:58:30]
  • 评测
  • 测评结果:90
  • 用时:6423ms
  • 内存:5036kb
  • [2024-07-25 21:58:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bool query(int);
void modify(int, bool);
bool WereYouLast(int n, int m) {
	if(m <= 10) {
		int p = log2(n);
		int s[15], t = 0;
		for(int i = 0, pos = 1; i <= p; i++) s[i] = query(i + 1), t += pos * s[i], pos *= 2;
		if(t == n) return true;
		for(int i = 0; i <= p; i++) modify(i + 1, t % 2), t >>= 1;
		return false;
	} else {
		int p = log2(n), x;
		int s[5], t;
		s[0] = query(p + 1 + 1), s[1] = query(p + 1 + 2), s[2] = query(p + 1 + 3), s[3] = query(p + 1 + 4), s[4] = query(p + 1 + 5); 
		t = s[0] + 2 * s[1] + 4 * s[2] + 8 * s[3] + 16 * s[4];
		x = query(t + 1);
		if(t == p) return true;
		if(x || t == p - 1) modify(t + 1, 0), t++;	
		else modify(t + 1, 1), t = 0;
		modify(p + 1 + 1, t & 1), modify(p + 1 + 2, (t / 2) & 1), modify(p + 1 + 3, (t / 4) & 1), modify(p + 1 + 4, (t / 8) & 1), modify(p + 1 + 5, (t / 16) & 1);
		return false;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3956kb

input:

1024 10

output:

12345876 -2 11

result:

wrong answer Invalid Operation At Position 11.

Subtask #2:

score: 20
Accepted

Test #2:

score: 20
Accepted
time: 3ms
memory: 4992kb

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: 100ms
memory: 5036kb

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: 6423ms
memory: 4968kb

input:

67108864 100000

output:

12345876 6 6

result:

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