# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824621 | LucaIlie | Minerals (JOI19_minerals) | C++17 | 28 ms | 2900 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 MAX_N = 43000;
const int UNDEF = -1;
int pairr[2 * MAX_N + 1], perm[2 * MAX_N + 1];
void solve( vector <int> &v ) {
int n = v.size() / 2, ln = n / 2;
vector<int> left, right;
if ( n == 1 ) {
pairr[v[0]] = v[1];
pairr[v[1]] = v[0];
return;
}
for ( int i: v ) {
if ( left.size() == ln * 2 || Query( perm[i] ) > ln ) {
right.push_back( i );
if ( left.size() < ln * 2 )
Query( perm[i] );
} else
left.push_back( i );
}
for ( int i: left )
Query( perm[i] );
solve( left );
solve( right );
}
void Solve( int n ) {
vector<int> v;
for ( int i = 1; i <= 2 * n; i++ ) {
pairr[i] = UNDEF;
v.push_back( i );
perm[i] = i;
}
random_shuffle( perm + 1, perm + 1 + 2 * n );
solve( v );
for ( int i = 1; i <= 2 * n; i++ ) {
if ( pairr[i] < i )
Answer( perm[i], perm[pairr[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... |