#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
const int MX = 105;
int par[MX];
int find(int nw){
return par[nw] = (par[nw] == nw ? nw : find(par[nw]));
}
mt19937 rng(time(NULL));
int ban[MX][MX];
void run(int N){
for(int i = 1; i <= N; i ++)
par[i] = i;
for(int times = 1; times < N; times ++){
memset(ban, 0, sizeof(ban));
vector<int> color(N + 1, -1), lf, rg;
set<vector<int> > cc;
int gt = 0;
do{
int mx = 0;
for(int _ = 0; _ < 200; _ ++){
for(int i = 1; i <= N; i ++) if(find(i) == i)
color[i] = rng() % 2;
for(int i = 1; i <= N; i ++) color[i] = color[find(i)];
if(cc.count(color)) continue;
cc.insert(color);
vector<int> nlf, nrg;
for(int i = 1; i <= N; i ++)
if(color[i]) nrg.push_back(i);
else nlf.push_back(i);
int cnt = 0;
for(int i : nlf) for(int j : nrg) cnt += !ban[i][j];
if(mx < cnt){
mx = cnt; lf = nlf; rg = nrg;
}
}
int xl[lf.size()], xr[rg.size()];
for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
for(int i = 0; i < rg.size(); i ++) xr[i] = rg[i];
if(lf.empty() || rg.empty()) continue;
gt = query(lf.size(), rg.size(), xl, xr);
if(gt == 0){
for(int i : lf) for(int j : rg) ban[i][j] = ban[j][i] = 1;
}
}while(gt == 0);
int l = 0, r = rg.size() - 1, rs = r + 1;
for(int md; l <= r;){
md = (l + r) / 2;
vector<int> nrg;
for(int j = 0; j <= md; j ++) nrg.push_back(rg[j]);
int xl[lf.size()], xr[nrg.size()];
for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
gt = query(lf.size(), nrg.size(), xl, xr);
if(gt){
rs = md; r = md - 1;
}else{
l = md + 1;
}
}
int u = rg[rs]; rg.clear(); rg.push_back(u);
swap(lf, rg);
l = 0, r = rg.size() - 1, rs = r + 1;
for(int md; l <= r;){
md = (l + r) / 2;
vector<int> nrg;
for(int j = 0; j <= md; j ++) nrg.push_back(rg[j]);
int xl[lf.size()], xr[nrg.size()];
for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
gt = query(lf.size(), nrg.size(), xl, xr);
if(gt){
rs = md; r = md - 1;
}else{
l = md + 1;
}
}
int v = rg[rs];
setRoad(u, v);
u = find(u); v = find(v);
par[u] = v;
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:40:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
| ~~^~~~~~~~~~~
icc.cpp:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0; i < rg.size(); i ++) xr[i] = rg[i];
| ~~^~~~~~~~~~~
icc.cpp:55:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
| ~~^~~~~~~~~~~
icc.cpp:56:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
| ~~^~~~~~~~~~~~
icc.cpp:74:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
| ~~^~~~~~~~~~~
icc.cpp:75:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
468 KB |
Ok! 103 queries used. |
2 |
Correct |
7 ms |
592 KB |
Ok! 101 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
804 KB |
Ok! 533 queries used. |
2 |
Incorrect |
781 ms |
920 KB |
Number of queries more than 5000 out of 2500 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
276 ms |
1092 KB |
Ok! 1350 queries used. |
2 |
Incorrect |
1436 ms |
1500 KB |
Number of queries more than 4500 out of 2250 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
362 ms |
1284 KB |
Ok! 1402 queries used. |
2 |
Correct |
423 ms |
1276 KB |
Ok! 1453 queries used. |
3 |
Correct |
681 ms |
1280 KB |
Ok! 1694 queries used. |
4 |
Correct |
276 ms |
1108 KB |
Ok! 1331 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
679 ms |
1388 KB |
Ok! 1691 queries used. |
2 |
Correct |
731 ms |
1276 KB |
Ok! 1704 queries used. |
3 |
Correct |
703 ms |
1272 KB |
Ok! 1722 queries used. |
4 |
Correct |
584 ms |
1280 KB |
Ok! 1630 queries used. |
5 |
Correct |
375 ms |
1112 KB |
Ok! 1423 queries used. |
6 |
Correct |
586 ms |
1100 KB |
Ok! 1613 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
689 ms |
1272 KB |
Too many queries! 1691 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |