This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <cstring>
struct cat_stack{
int stack[5000005], sz;
bool key;
void init(){
sz = 2e6;
memset(stack,0,sizeof(stack));
}
void filp(){
for(int i=0; i<sz; i++) stack[i] ^= 1;
}
int top(){
return stack[sz-1];
}
void pop(){
if(sz != 0) sz--;
}
void push(int x){
stack[sz++] = x;
}
void add(){
int x = top();
pop();
x += top();
pop();
push(x);
}
}s1,s2;
int main(){
int q;
scanf("%d",&q);
while (q--) {
int x,l,n;
scanf("%d %d %d",&x,&l,&n);
s1.init();
s2.init();
while (x>0) {
s2.push(s1.top());
s1.pop();
s1.filp();
if(s2.top() > l){
x--;
if(x == 0){
printf("%d\n",s2.top());
break;
}
}
else{
s2.push(n);
s2.push(n);
s2.add();
s2.add();
s1.push(s2.top());
s1.push(s2.top());
s2.pop();
s2.pop();
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |