# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997616 | TimDee | Minerals (JOI19_minerals) | C++17 | 30 ms | 3660 KiB |
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;
#define pb push_back
void Solve(vector<int> l, vector<int> r, int in)
{
if(l.size()==1)
{
Answer(l[0],r[0]);
return;
}
int pre;
vector<int> L[2],R[2];
int sz=l.size()/2;
if(l.size()==2) sz=1;
for(int i=0;i<l.size();i++) L[i>=sz].pb(l[i]);
for(int i:L[0]) pre=Query(i);
for(int i:r)
{
if(L[0].size()==R[0].size()) R[1].pb(i);
else if(L[1].size()==R[1].size()) R[0].pb(i);
else
{
int now=Query(i);
if(now==pre)
{
if(in) R[1].pb(i);
else R[0].pb(i);
}
else
{
if(in) R[0].pb(i);
else R[1].pb(i);
}
pre=now;
}
}
Solve(L[0],R[0],in^1);
Solve(L[1],R[1],in);
}
void Solve(int n)
{
srand(time(0));
vector<int> l,r;
int pre=0;
for(int i=1;i<=n*2;i++)
{
int now=Query(i);
if(now!=pre) l.pb(i);
else r.pb(i);
pre=now;
}
Solve(l,r,1);
}
Compilation message (stderr)
# | 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... |