#include <bits/stdc++.h>
using namespace std;
#define int long long
int popcount(int x) {
int ans = 0;
while(x != 0) {
ans += (x&1);
x >>= 1;
}
return ans;
}
int greed(int x, int l, int n) {
int period = (l+2*n-1)/(2*n)*4;
x %= period;
//cout << x << " " << period << endl;
return (l+2*n-1)/(2*n)*2*n+popcount(x)%2;
}
int simulate(int x, int l, int n) {
vector<int> st1(100000, 0);
/*int period = (l+2*n-1)/(2*n)*4;
x %= period;*/
int t2;
int counter = x+1;
while(counter > 0) {
t2 = st1.back();
st1.pop_back();
for(int& i : st1) i ^= 1;
if(t2 > l) {
--counter;
//cout << counter << ": " << t2 << endl;
} else {
t2 += 2*n;
st1.push_back(t2);
st1.push_back(t2);
}
}
return t2;
}
signed main() {
int q;
cin >> q;
while(q--) {
int x, l, n;
cin >> x >> l >> n; --x;
cout << simulate(x, l, n) << " " << greed(x, l, n) << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1565 ms |
1916 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1569 ms |
1916 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1573 ms |
1928 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1573 ms |
1928 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1577 ms |
1944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1584 ms |
1944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |