/// sincer nu inteleg dc sunt asa proasta
#include <bits/stdc++.h>
#include "icc.h"
#define DIM 200
using namespace std;
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 run (int n){
int k,k2,el,i,x,y;
for (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<9;bit++){
k = 0, k2 = 0;
for (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
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);
if (t[x] > t[y])
swap (x,y);
for (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];
break;
}
}
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:27:14: warning: unused variable 'el' [-Wunused-variable]
int k,k2,el,i,x,y;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
512 KB |
Ok! 96 queries used. |
2 |
Correct |
10 ms |
512 KB |
Ok! 101 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
512 KB |
Ok! 548 queries used. |
2 |
Correct |
49 ms |
512 KB |
Ok! 683 queries used. |
3 |
Correct |
47 ms |
512 KB |
Ok! 670 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
512 KB |
Ok! 1491 queries used. |
2 |
Correct |
146 ms |
512 KB |
Ok! 1663 queries used. |
3 |
Correct |
137 ms |
512 KB |
Ok! 1615 queries used. |
4 |
Correct |
136 ms |
512 KB |
Ok! 1522 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
512 KB |
Ok! 1582 queries used. |
2 |
Correct |
138 ms |
512 KB |
Ok! 1569 queries used. |
3 |
Correct |
144 ms |
560 KB |
Ok! 1642 queries used. |
4 |
Correct |
134 ms |
760 KB |
Ok! 1531 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
143 ms |
512 KB |
Ok! 1618 queries used. |
2 |
Correct |
143 ms |
632 KB |
Ok! 1628 queries used. |
3 |
Correct |
147 ms |
512 KB |
Ok! 1641 queries used. |
4 |
Correct |
143 ms |
512 KB |
Ok! 1623 queries used. |
5 |
Correct |
132 ms |
512 KB |
Ok! 1525 queries used. |
6 |
Correct |
144 ms |
568 KB |
Ok! 1571 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
568 KB |
Ok! 1623 queries used. |
2 |
Incorrect |
148 ms |
632 KB |
Too many queries! 1667 out of 1625 |