# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
166896 |
2019-12-04T13:34:51 Z |
luciocf |
ICC (CEOI16_icc) |
C++14 |
|
272 ms |
704 KB |
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
const int maxn = 110;
int pai[maxn], peso[maxn];
int A[maxn], B[maxn];
vector<int> comp[maxn];
void init(int n)
{
for (int i = 1; i <= n; i++)
{
pai[i] = i, peso[i] = 1;
comp[i].push_back(i);
}
}
int Find(int x)
{
if (pai[x] == x) return x;
return pai[x] = Find(pai[x]);
}
void Join(int x, int y)
{
x = Find(x), y = Find(y);
if (x == y) return;
if (peso[x] < peso[y]) swap(x, y);
pai[y] = x, peso[x] += peso[y];
for (auto v: comp[y])
comp[x].push_back(v);
}
void run(int n)
{
init(n);
for (int e = 1; e < n; e++)
{
for (int b = 0; b < 7; b++)
{
int sz_a = -1, sz_b = -1;
for (int i = 1; i <= n; i++)
{
if (Find(i) == i)
{
if (i&(1<<b))
{
for (auto v: comp[i])
A[++sz_a] = v;
}
else
{
for (auto v: comp[i])
B[++sz_b] = v;
}
}
}
if (!query(sz_a+1, sz_b+1, A, B)) continue;
int ini = 0, fim = sz_a, ans = -1;
while (ini <= fim)
{
int mid = (ini+fim)>>1;
if (query(mid+1, sz_b+1, A, B)) ans = mid, fim = mid-1;
else ini = mid+1;
}
ini = 0, fim = sz_b;
int ans2 = -1;
while (ini <= fim)
{
int mid = (ini+fim)>>1;
if (query(ans+1, mid+1, A, B)) ans2 = mid, fim = mid-1;
else ini = mid+1;
}
setRoad(A[ans], B[ans2]);
Join(A[ans], B[ans2]);
break;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
504 KB |
Ok! 113 queries used. |
2 |
Correct |
10 ms |
504 KB |
Ok! 110 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
504 KB |
Ok! 562 queries used. |
2 |
Correct |
51 ms |
504 KB |
Ok! 692 queries used. |
3 |
Correct |
51 ms |
504 KB |
Ok! 684 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
130 ms |
568 KB |
Ok! 1358 queries used. |
2 |
Correct |
166 ms |
704 KB |
Ok! 1702 queries used. |
3 |
Correct |
128 ms |
576 KB |
Ok! 1341 queries used. |
4 |
Correct |
148 ms |
508 KB |
Ok! 1552 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
568 KB |
Ok! 1405 queries used. |
2 |
Correct |
139 ms |
504 KB |
Ok! 1444 queries used. |
3 |
Correct |
160 ms |
504 KB |
Ok! 1652 queries used. |
4 |
Correct |
130 ms |
564 KB |
Ok! 1325 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
162 ms |
636 KB |
Ok! 1655 queries used. |
2 |
Correct |
175 ms |
568 KB |
Ok! 1651 queries used. |
3 |
Correct |
166 ms |
564 KB |
Ok! 1670 queries used. |
4 |
Correct |
157 ms |
600 KB |
Ok! 1598 queries used. |
5 |
Correct |
142 ms |
572 KB |
Ok! 1467 queries used. |
6 |
Correct |
272 ms |
560 KB |
Ok! 1579 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
162 ms |
504 KB |
Too many queries! 1641 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |