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>
using namespace std;
const int nx=5e4+5;
int n, p, c, l[nx], r[nx], t;
vector<int> used, v, qrs[nx];
void Solve(int N) {
v.push_back(0);
used.push_back(0);
for (int i=1; i<=2*N; i++)
{
c=Query(i);
if (c==p) v.push_back(i);
else used.push_back(i), p=c;
}
for (int i=1; i<=N; i++) l[i]=1, r[i]=N;
while (++t)
{
bool f=1;
for (int i=1; i<=N; i++) qrs[i].clear();
for (int i=1; i<=N; i++) if (l[i]!=r[i]) f=0, qrs[(l[i]+r[i])/2].push_back(i);
if (f) break;
//cout<<"bsearch\n";
//for (int i=1; i<=N; i++) cout<<i<<' '<<v[i]<<' '<<l[i]<<' '<<r[i]<<'\n';
if (t%2)
{
p=N;
for (int i=N; i>=1; i--)
{
for (auto x:qrs[i])
{
//cout<<"here "<<x<<' '<<p<<'\n';
if (Query(v[x])==p) r[x]=i;
else l[x]=i+1, p--;
}
p=Query(used[i]);
}
}
else
{
p=0;
for (int i=1; i<=N; i++)
{
p=Query(used[i]);
for (auto x:qrs[i])
{
if (Query(v[x])==p) r[x]=i;
else l[x]=i+1, p++;
}
}
}
}
for (int i=1; i<=N; i++) Answer(v[i], used[l[i]]);
}
# | 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... |