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 "icc.h"
using namespace std;
static int c[105], v1[105], v2[105];
static void solve(int m1, int v1[], int m2, int v2[]){
int i, mid;
while(m1 > 1){
mid = m1 / 2;
if(query(mid, m2, v1, v2) == 1){
m1 = mid;
}
else{
for(i = mid; i < m1; i++){
v1[i - mid] = v1[i];
}
m1 -= mid;
}
}
}
void run(int n){
int nr, i, ii, m1, m2, k, x, y;
nr = n;
for(i = 1; i <= n; i++){
c[i] = i;
}
for(k = 1; k < n; k++){
for(ii = 0; (1 << ii) < nr; ii++){
m1 = m2 = 0;
for(i = 1; i <= n; i++){
if( ( (c[i] >> ii) & 1) == 0){
v1[m1++] = i;
}
else{
v2[m2++] = i;
}
}
if(query(m1, m2, v1, v2) == 1){
break;
}
}
m1 = m2 = 0;
for(i = 1; i <= n; i++){
if( ( (c[i] >> ii) & 1) == 0){
v1[m1++] = i;
}
else{
v2[m2++] = i;
}
}
solve(m1, v1, m2, v2);
solve(m2, v2, m1, v1);
x = v1[0];
y = v2[0];
setRoad(x, y);
if(c[x] > c[y]){
swap(x, y);
}
for(i = 1; i <= n; i++){
if(i != y && c[i] == c[y]){
c[i] = c[x];
}
else{
if(c[i] > c[y]){
c[i]--;
}
}
}
c[y] = c[x];
nr--;
}
}
# | 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... |