# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
362433 |
2021-02-03T07:52:58 Z |
alextodoran |
ICC (CEOI16_icc) |
C++17 |
|
153 ms |
748 KB |
/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
typedef long long ll;
const int N_MAX = 102;
const int BITS = 7;
int query (int sa, int sb, int a[], int b[]);
void setRoad (int a, int b);
vector <int> edges[N_MAX];
vector <int> component[N_MAX];
int cntComponents;
bool visited[N_MAX];
void dfs (int u)
{
visited[u] = true;
component[cntComponents].push_back(u);
for(int v : edges[u])
if(visited[v] == false)
dfs(v);
}
int a[N_MAX], b[N_MAX];
int ca[N_MAX], cb[N_MAX];
void run (int n)
{
for(int t = 1; t < n; t++)
{
int U, V;
for(int i = 1; i <= n; i++)
visited[i] = false;
for(int i = 1; i <= n; i++)
if(visited[i] == false)
{
cntComponents++;
dfs(i);
}
int cnta, cntb;
for(int bit = 0; bit < BITS; bit++)
{
cnta = 0;
cntb = 0;
for(int i = 1; i <= cntComponents; i++)
if((i >> bit) & 1)
{
for(int u : component[i])
a[cnta++] = u;
}
else
{
for(int u : component[i])
b[cntb++] = u;
}
if(query(cnta, cntb, a, b) == true)
break;
}
int l, r;
l = 0;
r = cnta - 1;
while(l < r)
{
int mid = ((l + r) >> 1);
if(query(mid - l + 1, cntb, a + l, b) == true)
r = mid;
else
l = mid + 1;
}
U = a[l];
l = 0;
r = cntb - 1;
while(l < r)
{
int mid = ((l + r) >> 1);
if(query(cnta, mid - l + 1, a, b + l) == true)
r = mid;
else
l = mid + 1;
}
V = b[l];
setRoad(U, V);
edges[U].push_back(V);
edges[V].push_back(U);
for(int i = 1; i <= cntComponents; i++)
component[i].clear();
cntComponents = 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
492 KB |
Ok! 95 queries used. |
2 |
Correct |
6 ms |
492 KB |
Ok! 93 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
620 KB |
Ok! 528 queries used. |
2 |
Correct |
46 ms |
492 KB |
Ok! 657 queries used. |
3 |
Correct |
46 ms |
620 KB |
Ok! 642 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
492 KB |
Ok! 1373 queries used. |
2 |
Correct |
148 ms |
620 KB |
Ok! 1596 queries used. |
3 |
Correct |
146 ms |
492 KB |
Ok! 1596 queries used. |
4 |
Correct |
139 ms |
584 KB |
Ok! 1474 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
748 KB |
Ok! 1464 queries used. |
2 |
Correct |
130 ms |
492 KB |
Ok! 1471 queries used. |
3 |
Correct |
136 ms |
492 KB |
Ok! 1547 queries used. |
4 |
Correct |
133 ms |
492 KB |
Ok! 1489 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
149 ms |
620 KB |
Ok! 1553 queries used. |
2 |
Correct |
135 ms |
620 KB |
Ok! 1521 queries used. |
3 |
Correct |
138 ms |
492 KB |
Ok! 1571 queries used. |
4 |
Correct |
142 ms |
620 KB |
Ok! 1540 queries used. |
5 |
Correct |
129 ms |
492 KB |
Ok! 1455 queries used. |
6 |
Correct |
142 ms |
492 KB |
Ok! 1534 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
492 KB |
Ok! 1544 queries used. |
2 |
Correct |
153 ms |
620 KB |
Ok! 1590 queries used. |