This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(0);
void run(int N){
for(int i = 1; i <= N; i ++)
par[i] = i;
for(int times = 1; times < N; times ++){
vector<int> color(N + 1, -1), lf, rg;
int gt = 0;
for(int xx = 0; xx <= 7; xx ++){
int i = xx;
int tp = 1;
for(int j = 1; j <= N; j ++) if(find(j) == j){
if(tp & (1 << i)) color[j] = 1;
else color[j] = 0;
tp ++;
}
for(int j = 1; j <= N; j ++) color[j] = color[find(j)];
lf.clear(); rg.clear();
for(int j = 1; j <= N; j ++)
if(color[j] == 1) lf.push_back(j);
else rg.push_back(j);
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 == 1) break;
}
int l = 0, r = (int)rg.size() - 1;
for(int md; l < r;){
md = (l + r) / 2;
vector<int> nrg;
for(int j = l; 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){
r = md;
}else{
l = md + 1;
}
}
int u = rg[r]; rg.clear(); rg.push_back(u);
swap(lf, rg);
l = 0, r = (int)rg.size() - 1;
for(int md; l < r;){
md = (l + r) / 2;
vector<int> nrg;
for(int j = l; 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){
r = md;
}else{
l = md + 1;
}
}
int v = rg[r];
setRoad(u, v);
u = find(u); v = find(v);
par[v] = u;
}
}
Compilation message (stderr)
icc.cpp: In function 'void run(int)':
icc.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
| ~~^~~~~~~~~~~
icc.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i = 0; i < rg.size(); i ++) xr[i] = rg[i];
| ~~^~~~~~~~~~~
icc.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
| ~~^~~~~~~~~~~
icc.cpp:47:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
| ~~^~~~~~~~~~~~
icc.cpp:66:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
| ~~^~~~~~~~~~~
icc.cpp:67:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int i = 0; i < nrg.size(); i ++) xr[i] = nrg[i];
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |