# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
250172 | SomeoneUnknown | Minerals (JOI19_minerals) | C++14 | 14 ms | 512 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;
const int b = 208;
void Solve(int N) {
queue<int> firsts, mbox;
for(int i = 1; i <= 2*N; i++){
int res = Query(i);
if(firsts.size() < res){
firsts.push(i);
}else{
mbox.push(i);
}
if(mbox.size() >= b){
queue<int> ftrash;
while(!mbox.empty()){
int examining = firsts.front();
firsts.pop();
int res2 = Query(examining);
if(firsts.size() < res2){
while(Query(mbox.front()) == res2){
Query(mbox.front());
mbox.push(mbox.front());
mbox.pop();
}
Answer(examining, mbox.front());
mbox.pop();
}else{
firsts.push(examining);
Query(examining);
}
}
}
}
if(mbox.size() != firsts.size()) int a = 1/0;
while(!mbox.empty()){
int res2 = Query(firsts.front());
while(Query(mbox.front()) == res2){
Query(mbox.front());
mbox.push(mbox.front());
mbox.pop();
}
Answer(firsts.front(), mbox.front());
mbox.pop();
firsts.pop();
}
/*int v = Query(1);
for (int i = 1; i <= N; ++i) {
Answer(i, 2 * N + 1 - i);
}//*/
}
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... |