#include<bits/stdc++.h>
#include<icc.h>
#define ll int
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>
using namespace :: std;
const ll mod=1e9+7;
const ll maxn=500;
const ll inf=1e9+900;
vector<ll> vec[maxn];
ll par[maxn];
int soal(vector<ll> a,vector<ll> b){
ll A[maxn];
ll B[maxn];
for(ll i=0;i<(ll)a.size();i++){
A[i]=a[i];
}
for(ll i=0;i<b.size();i++){
B[i]=b[i];
}
return query(a.size(),b.size(),A,B);
}
vector<ll> kamel(vector<ll> v){
vector<ll> ans;
for(auto e:v){
for(auto r:vec[e]){
ans.pb(r);
}
}
return ans;
}
ll find_sar(vector<ll> a,vector<ll> b){
while(a.size()>1){
vector<ll> aa,aaa;
for(ll i=0;i<(ll)a.size()/2;i++){
aa.pb(a[i]);
}
for(ll i=(ll)a.size()/2;i<a.size();i++){
aaa.pb(a[i]);
}
bool bo=soal(aa,b);
if(bo){
a=aa;
}else{
a=aaa;
}
}
return a[0];
}
void run(ll n){
for(ll i=1;i<=n;i++){
vec[i].pb(i);
par[i]=i;
}
for(ll w=1;w<=n-1;w++){
vector<ll> imp;
for(ll i=1;i<=n;i++){
if(vec[i].size()){
imp.pb(i);
}
}
ll m=imp.size();
vector<ll> v1,v0;
for(ll i=0;(1<<i)<m;i++){
v0.clear();
v1.clear();
for(ll j=0;j<m;j++){
if((j>>i)&1){
v1.pb(imp[j]);
}else{
v0.pb(imp[j]);
}
}
int b=soal(kamel(v0),kamel(v1));
if(b){
break;
}
}
ll s=find_sar(kamel(v0),kamel(v1));
ll t=find_sar(kamel(v1),kamel(v0));
setRoad(s,t);
s=par[s];
t=par[t];
for(auto e:vec[s]){
vec[t].pb(e);
par[e]=t;
}
vec[s].clear();
}
}
Compilation message
icc.cpp: In function 'int soal(std::vector<int>, std::vector<int>)':
icc.cpp:27:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i=0;i<b.size();i++){
~^~~~~~~~~
icc.cpp: In function 'int find_sar(std::vector<int>, std::vector<int>)':
icc.cpp:47:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i=(ll)a.size()/2;i<a.size();i++){
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
512 KB |
Ok! 94 queries used. |
2 |
Correct |
7 ms |
512 KB |
Ok! 101 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
512 KB |
Ok! 541 queries used. |
2 |
Correct |
75 ms |
512 KB |
Ok! 694 queries used. |
3 |
Correct |
42 ms |
512 KB |
Ok! 681 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
116 ms |
572 KB |
Ok! 1456 queries used. |
2 |
Correct |
132 ms |
512 KB |
Ok! 1704 queries used. |
3 |
Correct |
127 ms |
604 KB |
Ok! 1584 queries used. |
4 |
Correct |
127 ms |
512 KB |
Ok! 1522 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
126 ms |
540 KB |
Ok! 1525 queries used. |
2 |
Correct |
119 ms |
584 KB |
Ok! 1472 queries used. |
3 |
Correct |
127 ms |
576 KB |
Ok! 1614 queries used. |
4 |
Correct |
125 ms |
572 KB |
Ok! 1526 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
118 ms |
584 KB |
Ok! 1615 queries used. |
2 |
Correct |
120 ms |
580 KB |
Ok! 1614 queries used. |
3 |
Correct |
119 ms |
604 KB |
Ok! 1614 queries used. |
4 |
Correct |
124 ms |
512 KB |
Ok! 1630 queries used. |
5 |
Correct |
113 ms |
512 KB |
Ok! 1504 queries used. |
6 |
Correct |
132 ms |
640 KB |
Ok! 1562 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
512 KB |
Ok! 1614 queries used. |
2 |
Incorrect |
131 ms |
588 KB |
Too many queries! 1704 out of 1625 |