# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
668368 |
2022-12-03T17:32:32 Z |
finn__ |
ICC (CEOI16_icc) |
C++17 |
|
3 ms |
468 KB |
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
size_t n;
int *c, *d;
void dfs(
vector<vector<unsigned>> const &g, unsigned u, vector<unsigned> &y,
vector<bool> &vis)
{
y.push_back(u);
vis[u] = 1;
for (unsigned v : g[u])
if (!vis[v])
dfs(g, v, y, vis);
}
void fill_order(vector<vector<unsigned>> const &g, vector<vector<unsigned>> &y)
{
vector<bool> vis(g.size(), 0);
y.clear();
for (unsigned i = 0; i < g.size(); i++)
{
if (!vis[i])
{
y.push_back({});
dfs(g, i, y.back(), vis);
}
}
}
size_t add_components(int *z, vector<vector<unsigned>> const &y, size_t a, size_t b)
{
size_t size = 0;
for (size_t i = a; i < b; i++)
{
for (unsigned u : y[i])
{
z[size] = u + 1;
size++;
}
}
return size;
}
void run(int N)
{
n = N;
c = (int *)malloc(n * sizeof(int));
d = (int *)malloc(n * sizeof(int));
vector<vector<unsigned>> g(n);
vector<vector<unsigned>> y;
for (unsigned z = 0; z < n - 1; z++)
{
fill_order(g, y);
size_t cs, ds;
while (1)
{
random_shuffle(y.begin(), y.end());
cs = add_components(c, y, 0, y.size() / 2);
ds = add_components(d, y, y.size() / 2, y.size());
if (query(cs, ds, c, d))
break;
}
size_t a = 0, b = cs;
while (a < b)
{
size_t mid = (a + b) / 2;
if (query(mid, ds, c, d))
b = mid;
else
a = mid + 1;
}
unsigned const u = c[a];
a = 0, b = ds;
while (a < b)
{
size_t mid = (a + b) / 2;
if (query(cs, mid, c, d))
b = mid;
else
a = mid + 1;
}
unsigned const v = d[a];
setRoad(u, v);
}
free(c);
free(d);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
424 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
2 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |