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"
using namespace std;
#include <vector>
#include <iostream>
int query(int x){return Query(x+1);}
int n;
struct mineral{
int a,b;
mineral(){a=0;b=n;}
};
vector<mineral> v;
void f(int a,int b){
//cerr<<a<<','<<b<<';';
for (int i=a;i<b;i++){
query(i);
}
for (int i=0;i<n;i++){
if (v[i].a<=a && v[i].b>=b){
if (query(i+n)>(b-a)){
v[i].a=b;
}else{
v[i].b=b;
}
query(i+n);
}
}
for (int i=a;i<b;i++){
query(i);
}
}
void Solve(int N) {
n=N;
v.resize(n,mineral());
vector<pair<int,int>> w;
w.push_back({0,N});
int a,b,c;
while (!w.empty()){
a=w[w.size()-1].first;
b=w[w.size()-1].second;
c=(a+b)/2;
w.pop_back();
if (a+1==b||a==b){continue;}
f(a,c);
w.push_back({a,c});
w.push_back({c,b});
}
for (int i=0;i<n;i++){
Answer(i+n+1,v[i].a+1);
}
}
# | 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... |