#include <bits/stdc++.h>
#include "icc.h"
#define DIM 200
using namespace std;
vector <int> L[DIM],comp[DIM],w;
int n,i,x,y,k,k2,el;
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;
}
*/
void _union (int x, int y){
if (t[x] > t[y])
swap (x,y);
for (int i=1;i<=n;i++){
if (i != y && t[i] == t[y])
t[i] = t[x];
else {
if (t[i] > t[y])
t[i]--;
}
}
t[y] = t[x];
}
void run (int n){
int k,k2,el;
for (int i=1;i<=n;i++)
t[i] = i;
for (int pas=1;pas<n;pas++){
/// impart componentele conexe in doua multimi
for (int bit=0;bit<8;bit++){
k = 0, k2 = 0;
for (int i=1;i<=n;i++){
int val = t[i];
if (val&(1<<bit))
a[k++] = i;
else b[k2++] = i;
}
if (!k || !k2)
continue;
if (query(k,k2,a,b)){ /// am gasit cele doua multimi
int val = k;
while (val > 1){
int mid = val/2;
if (query(mid,k2,a,b))
val = mid;
else {
for (int i=mid;i<val;i++)
a[i-mid] = a[i];
val -= mid;
}
}
x = a[0], k = 1;
val = k2;
while (val > 1){
int mid = val/2;
if (query(k,mid,a,b))
val = mid;
else {
for (int i=mid;i<val;i++)
b[i-mid] = b[i];
val -= mid;
}
}
y = b[0], k2 = 1;
setRoad(x,y);
_union (x,y);
break;
}
}
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:44:14: warning: unused variable 'el' [-Wunused-variable]
int k,k2,el;
^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
512 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
512 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
512 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
512 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
50 ms |
512 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
512 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |