이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(64, 0);
int t2;
int counter = x;
while(counter > 0) {
t2 = st1.back();
st1.pop_back();
for(int& i : st1) i ^= 1;
if(t2 > l) {
--counter;
//cout << 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) << '\n';
}
return 0;
}
# | 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... |