# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029452 | vjudge1 | CATS (NOI14_cats) | C++11 | 1565 ms | 262144 KiB |
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 <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
ll X,L,N,t;
int main(){
scanf("%lld",&t);
while(t--){
scanf("%lld %lld %lld",&X,&L,&N);
ll con=X;
stack<pair<ll,ll>> S1;
ll flip=0;
while(con>0){
ll T1;
ll aux;
if(S1.empty()){
T1=0;
aux=0;
}else{
T1=S1.top().F;
aux=S1.top().S;
S1.pop();
}
if((flip-aux)%2==1){
T1^=1;
}
//FLIP LAST BINARY BIT OF ALL NUMBERS IN S1
flip++;
if(T1>L){
con--;
if(con==0){
printf("%lld\n",T1);
}
}else{
ll f1=T1+2*N;
S1.push({f1,flip});
S1.push({f1,flip});
}
}
}
}
Compilation message (stderr)
# | 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... |