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 filp(){
key ^= 1;
for(int i=0; i<sz; i++) stack[i] ^= 1;
}
int top(){
if(sz == 0) return key;
return stack[sz-1];
}
void pop(){
if(sz != 0) sz--;
}
void push(int x){
stack[sz++] = x;
}
void print(){
puts("stack status from bottom to top");
for(int i=0; i<sz; i++) printf("%d\n",stack[i]);
}
}s1;
int main(){
int q;
scanf("%d",&q);
while (q--) {
int x,l,n;
scanf("%d %d %d",&x,&l,&n);
int s2 = 0;
s1.sz = 0;
s1.key = 0;
while (x) {
s2 = s1.top();
s1.pop();
s1.filp();
while (s2 <= l) {
s2 += 2*n;
s1.push(s2);
s1.push(s2);
s2 = s1.top();
s1.pop();
s1.filp();
}
if(s2 > l){
x--;
if(x == 0){
printf("\n%d\n",s2);
break;
}
}
}
}
}
# | 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... |