# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367250 | 2021-02-16T16:58:14 Z | mihai145 | ICC (CEOI16_icc) | C++14 | 0 ms | 0 KB |
// // Created by mihai145 on 16.02.2021. // #include <vector> #include <cmath> //#include "icc.h" using namespace std; const int NMAX = 100; int comp[NMAX + 2]; void run(int N) { for(int i = 1; i <= N; i++) { comp[i] = i - 1; } for(int c = N; c > 1; c--) { int log = log2(c); vector<int> A, B; for(int bit = 0; bit <= log; bit++) { vector<int> a, b; for(int i = 1; i <= N; i++) { if (comp[i] & (1 << bit)) a.push_back(i); else b.push_back(i); } int q = query((int)a.size(), (int)b.size(), a, b); if(q) { A = a; B = b; break; } } for(int step = 1; step <= 2; step++) { while((int)A.size() > 1) { vector<int> A1, A2; for(int i = 0; i < (int)A.size(); i++) { if(i % 2 == 0) { A1.push_back(A[i]); } else { A2.push_back(A[i]); } } int q = query((int)A1.size(), (int)B.size(), A1, B); if(q) { A = A1; } else { A = A2; } } swap(A, B); } setRoad(A[0], B[0]); int cA = comp[A[0]], cB = comp[B[0]]; for(int i = 1; i <= N; i++) if(comp[i] == cA) { comp[i] = cB; } } }