QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#491778 | #4912. WereYouLast | ddxrS | 100 ✓ | 6370ms | 5180kb | C++14 | 926b | 2024-07-25 22:02:54 | 2024-07-25 22:02:55 |
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;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 3952kb
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: 7ms
memory: 4988kb
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: 4968kb
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: 6370ms
memory: 5180kb
input:
67108864 100000
output:
12345876 6 6
result:
ok Correct Answer. C1 = 6. C2 = 6.