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 <vector>
#include <iostream>
#define int int64_t
using namespace std;
struct solver
{
int x, l, n;
vector<int> s1;
vector<int> s2;
void calc()
{
s1.resize(2, 0);
s2.resize(2, 0);
int ctr = 0;
while (x > 0)
{
if (s1.size() == 0) {s1.push_back(0);}
s2.push_back(s1.back() ^ ctr);
s1.pop_back();
ctr += 1; ctr %= 2;
if (s2.back() > l)
{
x--;
if (x == 0) cout << s2.back() << "\n";
}
else
{
if (s2.size() == 0) s2.push_back(0);
s2.back() += 2*n;
s1.push_back(s2.back() ^ ctr);
s1.push_back(s2.back() ^ ctr);
if (s2.size() != 0) s2.pop_back();
if (s2.size() != 0) s2.pop_back();
}
}
}
};
signed main()
{
//ios_base::sync_with_stdio(0);
//cin.tie(0);
int q;
cin >> q;
for (int c = 0; c < q; c++)
{
solver s;
cin >> s.x >> s.l >> s.n;
s.calc();
}
}
# | 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... |