# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
155961 |
2019-10-02T09:48:12 Z |
Minnakhmetov |
CATS (NOI14_cats) |
C++14 |
|
3 ms |
504 KB |
// #include <bits/stdc++.h>
// #define ll long long
// #define all(aaa) aaa.begin(), aaa.end()
// using namespace std;
// int f(ll x, ll y) {
// if (x == 0)
// return 0;
// if (x < y / 2)
// return f(x, y / 2);
// return f(x - y / 2, y / 2) ^ 1;
// }
// signed main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// int q;
// cin >> q;
// while (q--) {
// ll x, l, n;
// cin >> x >> l >> n;
// x--;
// cout << x << "\n";
// ll ans = 2 * (l / (n << 1) + 1) * n;
// cout << (ans ^ f(x, 1ll << 61)) << "\n";
// }
// return 0;
// }
#include <bits/stdc++.h>
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
using namespace std;
struct MyStack {
vector<int> v;
int flip = 0;
void push(int x) {
v.push_back(x);
}
int pop() {
if (!v.empty()) {
int x = v.back();
v.pop_back();
return x;
}
return flip;
}
int top() {
return v.empty() ? flip : v.back();
}
void add() {
push(pop() + pop());
}
};
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int q;
cin >> q;
while (q--) {
ll x, l, n;
cin >> x >> l >> n;
ll h = l / (n << 1) + 1;
ll ans = 2 * h * n;
x--;
x %= (2 << h);
while (x > 0) {
ans ^= (x & 1);
x >>= 1;
}
cout << ans << "\n";
// string sa, sb;
// MyStack s1, s2;
// int counter = x, j = 0, gg = 0;
// while (counter > 0) {
// s2.push(s1.pop());
// for (int &i : s1.v)
// i ^= 1;
// s1.flip ^= 1;
// // cout << "s1 : ";
// // for (int x : s1.v) {
// // cout << x / n << "n";
// // if (x % 2)
// // cout << "^1";
// // cout << ", ";
// // }
// // cout << "\n";
// // cout << "T2 = ";
// int x = s2.v.back();
// // cout << x / n << "\n";
// // if (x % 2)
// // cout << "^1";
// if (s2.top() > l) {
// counter--;
// gg++;
// if (gg % 2 == 0)
// sa.push_back(s2.top() % 2 + '0');
// else
// sb.push_back(s2.top() % 2 + '0');
// j++;
// // if (j % (1 << h) == 0)
// // cout << "\n";
// // if (counter == 0)
// // cout << s2.top() << "\n";
// }
// else {
// s2.push(n);
// s2.push(n);
// s2.add();
// s2.add();
// s1.push(s2.top());
// s1.push(s2.top());
// s2.pop();
// s2.pop();
// }
// }
// cout << sa << " " << sb << "\n";
// // COUNTER = X
// // WHILE COUNTER > 0
// // S2 PUSH T1 //Push the top element of S1 onto S2
// // S1 POP //Pop the top element of S1
// // FLIP LAST BINARY BIT OF ALL NUMBERS IN S1
// // IF T2 > L
// // COUNTER = COUNTER - 1
// // IF COUNTER == 0 PRINT T2
// // ELSE
// // S2 PUSH N
// // S2 PUSH N
// // S2 ADD
// // S2 ADD
// // S1 PUSH T2
// // S1 PUSH T2
// // S2 POP
// // S2 POP
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
504 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
504 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |