#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
int i,j,k,q,sa,sb,qu,l,r,m,x,alo,balo;
int parent[101],mas[101],a[101],b[101];
int fix[101],go[101][101];
int n;
void run(int n) {
srand(time(NULL));
for (i=1;i<=n;i++)
parent[i]=i;
for (j=1;j<n;j++) {
for (i=1;i<=n;i++)
fix[i]=0;
for (i=1;i<=n;i++)
fix[parent[i]]=1;
k=0;
for (i=1;i<=n;i++)
if (fix[i])
mas[k++]=i;
qu=0;
while (true) {
for (i=0;i<k;i++)
fix[mas[i]]=rand()%2;
sa=sb=0;
for (i=0;i<=n;i++)
a[i]=b[i]=0;
for (i=1;i<=n;i++) {
if (fix[parent[i]])
a[sa++]=i;
else
b[sb++]=i;
}qu++;
if (query(sa,sb,a,b))
break;
}
if (qu>20)return;
l=1;r=sa;
while (l!=r) {
m=(l+r)/2;
for (i=0;i<=n;i++)
mas[i]=0;
for (i=l;i<=m;i++)
mas[i-l]=a[i-1];
if (query(m-l+1,sb,mas,b))
r=m;
else
l=m+1;
}
x=l;
l=1;r=sb;
while (l!=r) {
m=(l+r)/2;
for (i=0;i<=n;i++)
mas[i]=0;
for (i=l;i<=m;i++)
mas[i-l]=b[i-1];
if (query(sa,m-l+1,a,mas))
r=m;
else
l=m+1;
}
int solo=parent[a[x-1]];
for (i=1;i<=n;i++)
if (parent[i]==solo)
parent[i]=parent[b[l-1]];
setRoad(b[l-1],a[x-1]);
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
504 KB |
Ok! 103 queries used. |
2 |
Correct |
9 ms |
504 KB |
Ok! 105 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
504 KB |
Ok! 539 queries used. |
2 |
Correct |
64 ms |
504 KB |
Ok! 828 queries used. |
3 |
Correct |
64 ms |
556 KB |
Ok! 800 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
504 KB |
Ok! 1492 queries used. |
2 |
Correct |
232 ms |
636 KB |
Ok! 2198 queries used. |
3 |
Correct |
164 ms |
508 KB |
Ok! 1651 queries used. |
4 |
Correct |
179 ms |
560 KB |
Ok! 1708 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
171 ms |
632 KB |
Ok! 1682 queries used. |
2 |
Correct |
169 ms |
504 KB |
Ok! 1692 queries used. |
3 |
Correct |
188 ms |
592 KB |
Ok! 1856 queries used. |
4 |
Correct |
155 ms |
504 KB |
Ok! 1549 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
188 ms |
504 KB |
Too many queries! 1839 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
186 ms |
632 KB |
Too many queries! 1820 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |