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 "minerals.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int cnt = 0;
vector<bool> done;
void pbs(int l, int r, bool right, bool reset, vector<int> X){
if(l == r){
for(int i: X) if(i < l) Answer(i, l), done[i] = 1;
return;
}
int md = (l+r)/2;
if(right) for(int i = l; i <= md; i++) cnt = Query(i);
else for(int i = r; i > md; i--) cnt = Query(i);
vector<int> A, B;
for(int i: X){
if(i > md){
B.push_back(i);
continue;
}
int cnt_ = Query(i);
if(cnt_ == cnt) A.push_back(i);
else B.push_back(i);
Query(i);
}
pbs(md+1, r, 1, 1, B);
pbs(l, md, 0, reset, A);
if(reset){
if(right) for(int i = l; i <= md; i++) cnt = Query(i);
else for(int i = r; i > md; i--) cnt = Query(i);
}
}
void Solve(int n){
vector<int> X;
for(int i = 1; i <= n; i++) X.push_back(i);
for(int i = 1; i <= n; i++) cnt = Query(i);
done.assign(2*n, 0);
pbs(n+1, 2*n, 1, 0, X);
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |