#include "icc.h"
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define fr first
#define sc second
#define pb push_back
#define ARRS ((ll)(2e6+100))
#define MAX ((ll)(2e9+100))
ll a[ARRS];
ll b[ARRS];
ll ca,cb;
ll pr[ARRS];
ll f[ARRS];
vector<ll> v[ARRS];
ll par(ll x){
if(x==pr[x])return x;
else return pr[x]=par(pr[x]);
}
void join(ll x,ll y){
x=par(x);
y=par(y);
if(x==y)return;
pr[y]=x;
}
//void setRoad(ll a,ll b){
// cout<<"------"<<endl;
// cout<<"PAS:"<<a<<" "<<b<<endl;
// cout<<endl;
//}
//ll query(ll n,ll m,ll *a,ll *b){
// cout<<n<<endl;
// for(int i=0; i<n; i++)cout<<a[i]<<" \n"[i==n-1];
// cout<<m<<endl;
// for(int i=0; i<m; i++)cout<<b[i]<<" \n"[i==m-1];
// cout<<"????\n";
// ll k;
// cin>>k;
// cout<<endl;
// return k;
//}
void run(int n){
srand(1337);
for(int i=1; i<=n; i++){
pr[i]=i;
v[i].pb(i);
}
vector<ll> va,vb;
for(int i=0; i<n-1; i++){
do{
for(int i=1; i<=n; i++)
f[i]=0;
ca=cb=0;
for(int i=1; i<=n; i++){
if(!f[par(i)])
f[par(i)]=rand()%2+1;
if(f[par(i)]==1)a[ca++]=i;
else b[cb++]=i;
}
}
while(!query(ca,cb,a,b));
va.clear();
vb.clear();
for(int i=1; i<=n; i++){
//if(i==par(i)){
if(f[par(i)]==1)va.pb(i);
else vb.pb(i);
//}
}
ll l=1,r=va.size();
while(l<r){
ll m=l+r>>1;
ca=0;
for(int i=0; i<m; i++){
//for(auto k:v[va[i]])
a[ca++]=va[i];
}
if(query(ca,cb,a,b))
r=m;
else l=m+1;
}
ca=1;
ll x=va[l-1];
a[0]=x;
l=1,r=vb.size();
while(l<r){
ll m=l+r>>1;
cb=0;
for(int i=0; i<m; i++){
//for(auto k:v[vb[i]])
b[cb++]=vb[i];
}
if(query(ca,cb,a,b))
r=m;
else l=m+1;
}
ll y=vb[l-1];
setRoad(x,y);
join(x,y);
}
}
//
//int main(){
// run(5);
//
//
//}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:82:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll m=l+r>>1;
~^~
icc.cpp:97:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
ll m=l+r>>1;
~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
47480 KB |
Ok! 104 queries used. |
2 |
Correct |
53 ms |
47620 KB |
Ok! 103 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
47792 KB |
Ok! 551 queries used. |
2 |
Correct |
116 ms |
47796 KB |
Ok! 848 queries used. |
3 |
Correct |
115 ms |
47796 KB |
Ok! 809 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
227 ms |
47796 KB |
Ok! 1462 queries used. |
2 |
Correct |
268 ms |
47796 KB |
Ok! 2116 queries used. |
3 |
Correct |
210 ms |
47796 KB |
Ok! 1705 queries used. |
4 |
Correct |
211 ms |
47796 KB |
Ok! 1703 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
47796 KB |
Ok! 1673 queries used. |
2 |
Correct |
223 ms |
47796 KB |
Ok! 1623 queries used. |
3 |
Correct |
277 ms |
47796 KB |
Ok! 1859 queries used. |
4 |
Correct |
193 ms |
47796 KB |
Ok! 1576 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
283 ms |
47796 KB |
Too many queries! 1863 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
253 ms |
47808 KB |
Too many queries! 1846 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |