/// sincer nu inteleg dc sunt asa proasta
#include <bits/stdc++.h>
#include "icc.h"
#define DIM 200
using namespace std;
int n;
int v[DIM],t[DIM],aux[DIM],a[DIM],b[DIM];
/*int query (int n, int m, int a[], int b[]){
int ans;
cout<<n<<" ";
for (int i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<endl;
cout<<m<<" ";
for (int i=0;i<m;i++)
cout<<b[i]<<" ";
cout<<endl;
cin>>ans;
return ans;
}
void setRoad (int x, int y){
cout<<x<<" "<<y<<endl;
}*/
int get_rad (int x){
while (t[x] > 0)
x = t[x];
return x;
}
void _union (int x, int y){
int radx = get_rad (x), rady = get_rad (y);
if (t[radx] < t[rady]){
t[radx] += t[rady];
t[rady] = radx;
} else {
t[rady] += t[radx];
t[radx] = rady;
}
}
void run (int n){
int k,k2,el,i,x,y;
for (i=1;i<=n;i++)
t[i] = -1;
for (int pas=1;pas<n;pas++){
/// impart componentele conexe in doua multimi
for (int bit=6;bit>=0;bit--){
k = 0, k2 = 0;
for (i=1;i<=n;i++){
int val = get_rad(i);
if (val&(1<<bit))
a[k++] = i;
else b[k2++] = i;
}
if (!k || !k2)
continue;
if (bit == 0 || query(k,k2,a,b)){ /// am gasit cele doua multimi
while (k > 1){
int mid = k/2;
if (query(mid,k2,a,b))
k = mid;
else {
for (int i=mid;i<k;i++)
a[i-mid] = a[i];
k -= mid;
}
}
x = a[0];
while (k2 > 1){
int mid = k2/2;
if (query(k,mid,a,b))
k2 = mid;
else {
for (int i=mid;i<k2;i++)
b[i-mid] = b[i];
k2 -= mid;
}
}
y = b[0];
setRoad(x,y);
_union (x,y);
break;
}
}
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:46:14: warning: unused variable 'el' [-Wunused-variable]
int k,k2,el,i,x,y;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
512 KB |
Ok! 104 queries used. |
2 |
Correct |
12 ms |
512 KB |
Ok! 102 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
512 KB |
Ok! 550 queries used. |
2 |
Correct |
57 ms |
512 KB |
Ok! 665 queries used. |
3 |
Correct |
58 ms |
512 KB |
Ok! 666 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
512 KB |
Ok! 1395 queries used. |
2 |
Correct |
168 ms |
512 KB |
Ok! 1651 queries used. |
3 |
Correct |
126 ms |
560 KB |
Ok! 1325 queries used. |
4 |
Correct |
164 ms |
636 KB |
Ok! 1592 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
512 KB |
Ok! 1381 queries used. |
2 |
Correct |
147 ms |
632 KB |
Ok! 1426 queries used. |
3 |
Correct |
165 ms |
560 KB |
Ok! 1635 queries used. |
4 |
Correct |
143 ms |
564 KB |
Ok! 1448 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
512 KB |
Ok! 1637 queries used. |
2 |
Correct |
166 ms |
560 KB |
Ok! 1650 queries used. |
3 |
Correct |
168 ms |
632 KB |
Ok! 1651 queries used. |
4 |
Correct |
167 ms |
512 KB |
Ok! 1652 queries used. |
5 |
Correct |
143 ms |
512 KB |
Ok! 1499 queries used. |
6 |
Correct |
176 ms |
512 KB |
Ok! 1639 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
177 ms |
512 KB |
Too many queries! 1670 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |