QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#491374 | #4912. WereYouLast | lifan | 100 ✓ | 5468ms | 5064kb | C++14 | 812b | 2024-07-25 19:08:10 | 2024-07-25 19:08:10 |
Judging History
answer
//
#include<bits/stdc++.h>
using namespace std;
bool query(int);
void modify(int,bool);
bool WereYouLast(int n,int m){
if(n==1024||m==10){
int x=0;
for(int i=1;i<=10;i++)x=x*2+query(i);
// cerr<<x<<' '<<n<<endl;
if(x==n-1)return 1;
x++;
for(int i=10;i>=1;i--)modify(i,x%2),x>>=1;
return 0;
}
else{
int x=0;
for(int i=1;i<=5;i++){
x=x*2+query(i);
}
int yy=0;
int nn=n;
while(nn)yy++,nn>>=1;
yy--;
if(x==yy)return 1;
else if(x==yy-1){
nn=yy;
for(int i=5;i>=1;i--){
modify(i,nn%2);
nn>>=1;
}
return 0;
}
else{
int op=query(100+x);
if(op){
modify(100+x,0);
x++;
}
else{
modify(100+x,1);
x=0;
}
for(int i=5;i>=1;i--){
modify(i,x%2);
x>>=1;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 3816kb
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: 5064kb
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: 80ms
memory: 4984kb
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: 5468ms
memory: 4980kb
input:
67108864 100000
output:
12345876 6 6
result:
ok Correct Answer. C1 = 6. C2 = 6.