# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
795629 | AbdullahMohammedAhmad | Minerals (JOI19_minerals) | C++14 | 21 ms | 4436 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;
deque<int> m;
void clear_queue()
{
while(!m.empty())
{
Query(m.back());
m.pop_back();
}
}
void Solve(int N) {
vector<vector<int>> prev1(1);
vector<vector<int>> prev2(1);
for(int i = 1; i <= 2*N; i++)
{
m.push_back(i);
if(Query(i) != m.size())
{
prev2[0].push_back(i);
Query(i);
m.pop_back();
}
else
{
prev1[0].push_back(i);
}
}
clear_queue();
while(prev1.size() < N)
{
vector<vector<int>> now1;
vector<vector<int>> now2;
for(int i = 0; i < prev1.size(); i++)
{
//ONE
if(prev1[i].size() == 1)
{
now1.push_back(prev1[i]);
now2.push_back(prev2[i]);
continue;
}
now1.push_back(vector<int>());
now1.push_back(vector<int>());
now2.push_back(vector<int>());
now2.push_back(vector<int>());
for(int j = 0; j < prev1[i].size(); j++)
{
if(j%2 == 0)
{
now1[now1.size()-2].push_back(prev1[i][j]);
m.push_back(prev1[i][j]);
Query(prev1[i][j]);
}
else
{
now1[now1.size()-1].push_back(prev1[i][j]);
}
}
for(int j = 0; j < prev2[i].size(); j++)
{
m.push_back(prev2[i][j]);
if(Query(prev2[i][j]) == m.size())
{
now2[now2.size()-1].push_back(prev2[i][j]);
Query(prev2[i][j]);
m.pop_back();
}
else
{
now2[now2.size()-2].push_back(prev2[i][j]);
Query(prev2[i][j]);
m.pop_back();
}
}
clear_queue();
}
prev1 = now1;
prev2 = now2;
}
for(int i = 0; i < N; i++)
{
Answer(prev1[i][0], prev2[i][0]);
}
}
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... |