#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
int f[110] , w[110] , a[110] , b[110];
void run (int n){
int i , p , q , bit;
for (i=1;i<=n;i++)
f[i] = i;
for (int mc = 1 ; mc < n ; mc++){
/// vreau sa ma duc in jos cat pot pana gasesc intervalul care contine capetele
bit = 0;
while (true){
/// o sa fac solutia aia mai proasta cu generat random pt ca nuj cum altcumva
p = q = 0;
for (i=1;i<=n;i++){
if (f[i] & (1 << bit))
a[p++] = i;
}
for (i=1;i<=n;i++){
if ((f[i] & (1 << bit)) == 0)
b[q++] = i;
}
if (query( p , q , a , b ) == 1){
/// un capat de muchie e intr o jumatate , celalalt capat in cealalta
break;
}
else {
/// ambele capete sunt in aceeasi jum
bit++;
continue;
}
}
/// ai vectorii a si b
/// a are p elem si b are q
/// a si b sunt indexate de la 0
/// pt a
while (p > 1){
if (query (p / 2 , q , a , b) == 1)
p/=2;
else {
for (i = p/2 ; i < p ; i++)
a[i - p/2] = a[i];
p = p - p / 2;
}
}
/// pt b
while (q > 1){
if (query (p , q / 2 , a , b) == 1)
q/=2;
else {
for (i = q/2 ; i < q ; i++)
b[i - q/2] = b[i];
q = q - q / 2;
}
}
setRoad(a[0] , b[0]);
/// acum trebuie sa modificam f ul
int u1 = min( f[a[0]] , f[b[0]] );
int u2 = max( f[a[0]] , f[b[0]] );
for (i=1;i<=n;i++){
if (f[i] == u2)
f[i] = u1;
else if (f[i] == n - mc + 1 && u2 != n - mc + 1)
f[i] = u2;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
504 KB |
Ok! 96 queries used. |
2 |
Correct |
9 ms |
504 KB |
Ok! 106 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
504 KB |
Ok! 536 queries used. |
2 |
Correct |
49 ms |
504 KB |
Ok! 678 queries used. |
3 |
Correct |
49 ms |
504 KB |
Ok! 681 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
133 ms |
568 KB |
Ok! 1498 queries used. |
2 |
Correct |
155 ms |
592 KB |
Ok! 1648 queries used. |
3 |
Correct |
143 ms |
504 KB |
Ok! 1636 queries used. |
4 |
Correct |
141 ms |
568 KB |
Ok! 1536 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
143 ms |
504 KB |
Ok! 1607 queries used. |
2 |
Correct |
142 ms |
632 KB |
Ok! 1589 queries used. |
3 |
Correct |
147 ms |
504 KB |
Ok! 1633 queries used. |
4 |
Correct |
137 ms |
588 KB |
Ok! 1534 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
146 ms |
504 KB |
Ok! 1613 queries used. |
2 |
Correct |
147 ms |
632 KB |
Ok! 1620 queries used. |
3 |
Correct |
146 ms |
632 KB |
Ok! 1638 queries used. |
4 |
Correct |
149 ms |
592 KB |
Ok! 1635 queries used. |
5 |
Correct |
137 ms |
560 KB |
Ok! 1538 queries used. |
6 |
Correct |
144 ms |
604 KB |
Ok! 1565 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
147 ms |
632 KB |
Ok! 1624 queries used. |
2 |
Incorrect |
155 ms |
564 KB |
Too many queries! 1667 out of 1625 |