#include <iostream>
#include <stack>
int main()
{
int q;
std::cin >> q;
while (q--)
{
int x, l, n;
std::cin >> x >> l >> n;
std::stack<int> s1;
int flipped = 0;
int t2 = 0;
s1.push(0);
s1.push(0);
int counter = x;
while (counter > 0)
{
t2 = s1.top() ^ flipped;
if (t2 > 1)
s1.pop();
flipped = !flipped;
if (t2 > l)
{
--counter;
if (counter == 0)
{
std::cout << t2 << "\n";
break;
}
}
else
{
s1.push((t2 + 2 * n) ^ flipped);
s1.push((t2 + 2 * n) ^ flipped);
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
248 KB |
Output is correct |
2 |
Correct |
7 ms |
356 KB |
Output is correct |
3 |
Correct |
9 ms |
436 KB |
Output is correct |
4 |
Correct |
7 ms |
508 KB |
Output is correct |
5 |
Correct |
8 ms |
584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
316 ms |
584 KB |
Output is correct |
2 |
Correct |
178 ms |
584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1565 ms |
584 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1577 ms |
1716 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1585 ms |
393216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1564 ms |
393216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |