# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
794728 | AbdullahMohammedAhmad | Minerals (JOI19_minerals) | C++14 | 1 ms | 336 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;
void Solve(int N) {
deque<int> in;
deque<int> order;
int prev_ans = 0, ans = 0;
for(int i = 1; i <= 2*N; i++){order.push_back(i);}
while(!order.empty())
{
ans = prev_ans = in.size();
in.push_back(order.front());
ans = Query(order.front());
order.pop_front();
if(ans != prev_ans){continue;}
vector<int> toput;
while(true)
{
prev_ans = ans;
int now = in.front();
ans = Query(now);
in.pop_front();
if(ans != prev_ans)
{
toput.push_back(now);
}
else
{
Answer(now, in.back());
in.pop_back();
break;
}
}
if(toput.empty()){continue;}
int dist = (int)order.size()/(int)toput.size();
int idx = dist;
for(int i = 0; i < toput.size(); i++)
{
if(idx >= order.size()-1)
{
order.push_back(toput[i]);
idx+=dist;
continue;
}
order.insert(order.begin()+idx, toput[i]);
idx+=dist;
}
}
}
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... |