제출 #13029

#제출 시각아이디문제언어결과실행 시간메모리
13029gs14004CATS (NOI14_cats)C++98
0 / 25
1500 ms20612 KiB
#include <cstdio>
#include <cstring>

struct cat_stack{
    int stack[5000005], sz;
    bool key;
    void filp(){
        key ^= 1;
    }
    int top(){
        if(sz == 0) return key;
        return stack[sz-1]^key;
    }
    void pop(){
        if(sz != 0) sz--;
    }
    void push(int x){
        stack[sz++] = x;
    }
}s1;

int main(){
    int q;
    scanf("%d",&q);
    while (q--) {
        int x,l,n;
        scanf("%d %d %d",&x,&l,&n);
        int s2 = 0;
        int rotten = 0;
        while (x>0) {
            s2 = s1.top();
            if(rotten) s2 ^= s1.key;
            s1.pop();
            s1.filp();
            rotten = 0;
            if(s2 > l){
                x--;
                if(x == 0){
                    printf("%d\n",s2);
                    break;
                }
            }
            else{
                s2 += 2*n;
                s1.push(s2^s1.key);
                s1.push(s2^s1.key);
                rotten = 1;
            }
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...