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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
struct Tree{
int val = 0, l, r;
Tree *lp, *rp;
Tree(int l, int r): l(l), r(r) {
if (l + 1 != r) {
lp = new Tree(l, (l + r) / 2);
rp = new Tree((l + r) / 2, r);
}
}
int query() {
if (l + 1 == r) {
// if (val) return -1;
val = 1;
return l;
}
val++;
if (lp->val == rp->val) return lp->query();
return rp->query();
}
};
int main() {
int n, k;
cin >> n >> k;
Tree t(1, (1 << n) + 1);
for (int i = 0; i < k - 1; i++){
t.query();
}
cout << t.query();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |