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;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef array<int, 2> ii;
//#define endl '\n'
void show(vector<ll> &a) {
int pt = a.size();
for_(i, 0, a.size()) if (a[i] != 0) {
pt = i;
break;
}
for_(i, pt, a.size()) cout << a[i] << " ";
cout << endl;
}
int main() {
#ifdef mlocal
freopen("test.in", "r", stdin);
// freopen("test.out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int t; cin >> t;
while (t--) {
ll x, l, n; cin >> x >> l >> n;
vector<ll> s1, s2;
for_(i,0, x+(2*l/n)+10) s1.push_back(0), s2.push_back(0);
int pt = 0;
while (x) {
pt++;
s2.push_back(s1.back());
s1.pop_back();
for_(i, 0, s1.size()) s1[i] = s1[i]^1;
// cout << "S1: "; show(s1);
if (s2.back() > l) {
// cout << "---------------------" << endl;
// cout << "iteration " << pt << endl;
// cout << "decrementeed!" << endl;
// cout << "S2: "; show(s2);
x--;
}
else {
s2[s2.size()-1] += 2*n; // push N, push N, add, add
s1.push_back(s2.back());
s1.push_back(s2.back());
s2.pop_back(); s2.pop_back();
}
// cout << "S1: "; show(s1);
// cout << "S2: "; show(s2);
}
cout << s2.back() << endl;
}
}
# | 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... |