# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
605816 |
2022-07-26T02:41:37 Z |
maximath_1 |
ICC (CEOI16_icc) |
C++11 |
|
17 ms |
548 KB |
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
const int MX = 105;
int que(vector<int> lf, vector<int> rg){
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()) return 0;
return query(lf.size(), rg.size(), xl, xr);
}
int par[MX];
int find(int nw){
return par[nw] = (par[nw] == nw ? nw : find(par[nw]));
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
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)];
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;
}
}
gt = que(lf, rg);
if(gt == 0){
for(int i : lf) for(int j : rg) ban[i][j] = ban[j][i] = 1;
}
}while(gt == 0);
while(lf.size() > 1 || rg.size() > 1){
shuffle(lf.begin(), lf.end(), rng);
shuffle(rg.begin(), rg.end(), rng);
vector<int> a, b;
if(lf.size() > 1){
for(int i = 0; i < lf.size(); i ++)
(i % 2 ? a : b).push_back(lf[i]);
if(que(a, rg)) lf = a;
else lf = b;
}
vector<int> RR;
for(int i : rg){
bool ok = 0;
for(int j : lf) if(!ban[i][j]){
ok = 1; break;
}
if(ok) RR.push_back(i);
}
rg = RR;
if(rg.size() > 1){
a.clear(); b.clear();
for(int i = 0; i < rg.size(); i ++)
(i % 2 ? a : b).push_back(rg[i]);
if(que(lf, a)) rg = a;
else rg = b;
}
vector<int> LL;
for(int i : lf){
bool ok = 0;
for(int j : rg) if(!ban[i][j]){
ok = 1; break;
}
if(ok) LL.push_back(i);
}
lf = LL;
}
int u = lf[0], v = rg[0];
setRoad(u, v);
u = find(u); v = find(v);
}
}
Compilation message
icc.cpp: In function 'int que(std::vector<int>, std::vector<int>)':
icc.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | for(int i = 0; i < lf.size(); i ++) xl[i] = lf[i];
| ~~^~~~~~~~~~~
icc.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for(int i = 0; i < rg.size(); i ++) xr[i] = rg[i];
| ~~^~~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(int i = 0; i < lf.size(); i ++)
| ~~^~~~~~~~~~~
icc.cpp:75:22: 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 < rg.size(); i ++)
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
548 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
548 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |