QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#491773 | #4912. WereYouLast | ddxrS | 90 | 6390ms | 5036kb | C++14 | 928b | 2024-07-25 21:59:25 | 2024-07-25 21:59:25 |
Judging History
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;
t++;
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;
}
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3872kb
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: 7ms
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: 97ms
memory: 4936kb
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: 6390ms
memory: 5032kb
input:
67108864 100000
output:
12345876 6 6
result:
ok Correct Answer. C1 = 6. C2 = 6.