# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128177 | OptxPrime | Minerals (JOI19_minerals) | C++14 | 2 ms | 376 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 <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>
#include <minerals.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define ans Answer
#define query Query
bool inside[100010];
int nn;
int curr,opencurr,tmp;
/* void Answer( int a, int b )
{
cout <<a << " " << b<< " par " <<endl;
}
int Query( int x )
{
cout<<x << " kveri " << tmp <<endl;
int t;
cin>>t;
return t;
}*/
void conquer( vector<int> vec )
{
// cout << " ponovo " <<endl;
int sz = vec.size();
if( sz==2 ){
ans( vec[0], vec[1] );
return;
}
// cout << " ciscenje " <<endl;
for( int i=1;i<=2*nn;i++ ){
if( inside[i] ) {
query( i ); /// ocistimo prethodno, sporo ciscenje samo za probu
inside[i]=false;
}
}
// cout << " gotovo ciscenje " <<endl;
int gsz=sz/2;
if( gsz%2==1 ) gsz++;
int opensz = gsz/2;
vector<int>vec1,vec2;
vec1.clear();
vec2.clear();
curr=0,opencurr=0;
for( int i=0;i<sz;i++ ){
if( vec1.size() >=gsz ){
vec.pb( vec[i] ); /// ako si popunio prvu grupu samo dodaj na drugu
}
else{
tmp = query( vec[i] );
inside[ vec[i] ] = true;
if( tmp > curr ){ /// zatvorila se neka iz prve grupe
vec1.pb( vec[i] );
curr=tmp;
}
else{
if( opencurr < opensz ){ /// otvorila se neka iz prve grupe
vec1.pb( vec[i] );
opencurr++;
}
else{ ///otvorila se neka iz druge grupe
vec2.pb( vec[i] );
curr= query( vec[i] );
inside[ vec[i] ]=false;
}
}
}
}
/// zaboravio sam ocistit kveri
// for( int i=0;i<vec1.size();i++ ) query[ vec[i] ]; /// ovo valjda ocisti kveri ? skontat fino kako se cisti
conquer( vec1 );
conquer( vec2 );
}
void Solve(int n)
{
nn=n;///globalno n
vector<int>vec;
vec.clear();
for ( int i=1;i<=2*n;i++){
vec.pb(i);
inside[i]=false;
}
conquer( vec );
}
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... |