# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675493 | QwertyPi | CATS (NOI14_cats) | C++14 | 1600 ms | 1028 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>
using namespace std;
vector<int> S1, S2;
void out(){
cout << "*****************" << endl;
cout << "S1: "; for(auto i : S1) cout << i << ' '; cout << endl;
cout << "S2: "; for(auto i : S2) cout << i << ' '; cout << endl;
}
int solve(int X, int L, int N){
int COUNTER = X;
S1.clear(); S2.clear();
S1.push_back(0); S2.push_back(0);
while(COUNTER){
S2.push_back(S1.back()); S1.pop_back();
for(auto& i : S1) i ^= 1;
if(S2.back() > L){
COUNTER--;
if(COUNTER == 0) return S2.back();
}else{
S2.back() += N * 2;
S1.push_back(S2.back());
S1.push_back(S2.back());
if(S2.size()) S2.pop_back();
if(S2.size()) S2.pop_back();
}
}
}
int main(){
int q; cin >> q;
for(int i = 0; i < q; i++){
int x, l, n; cin >> x >> l >> n;
cout << solve(x, l, n) << endl;
}
}
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... |