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>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define MAXN 1000005
using namespace std;
typedef long long ll;
typedef pair < int , int > ii;
int n, top = 1, a[MAXN], u[MAXN];
int myrandom(int x){
return rand()%x;
}
void Solve(int n) {n*= 2;
srand(time(0));
::n = n;
for(int i = 1; i <= n; i++)
a[i] = i;
random_shuffle(a + 1, a + n + 1, myrandom);
// for(int i = 1; i <= n; i++)
// cout << a[i] << " ";cout << endl;
// n *= 2;
for(int i = 1; i <= n; i++){
top++;
int don = top - Query(a[i]);
// cout << i << " " << don << endl;
if(don == 2){
for(int j = 1; j < i; j++){
if(u[a[j]])
continue;
top--;
int don = top - Query(a[j]);
// cout << j << " " << don << endl;
if(don == 1){
for(int k = j - 1; k >= 1; k--)
if(!u[a[k]]){
top++;
Query(a[k]);
}
u[a[j]] = u[a[i]] = 1;
// cout << "Buldum " << i << " " << j << endl;
Answer(a[i], a[j]);
top--;
Query(a[i]);
break;
}
}
// cout << "Bitti" << endl;
}
}
}
# | 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... |