# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372438 | Lam_lai_cuoc_doi | Airline Route Map (JOI18_airline) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
void Alice(int n, int m, vector<int> a, vector<int> b)
{
vector<pair<int, int>> s;
for (int i = 0; i < m; ++i)
s.emplace_back(a[i], b[i]);
for (int j = 0; j < 10; ++j)
{
for (int i = 0; i < n; ++i)
if (bit(j, i))
s.emplace_back(n + j, i);
if (j + 1 < 10)
s.emplace_back(j, j + 1);
}
for (int i = 0; i < n; ++i)
s.emplace_back(n + 10, i);
for (int i = 0; i < n + 10; ++i)
s.emplace_back(n + 11, i);
InitG(n + 12, s.size());
for (auto i : s)
MakeG(i.first, i.second);
}
void Bob(int n, int m, vector<int> a, vector<int> b)
{
int ten(-1), elv(-1), nin(-1), zer(-1);
vector<vector<bool>> adj(n, vector<bool>(n));
vector<pair<int, int>> s;
vector<int> cnt(n), real(n), son(n), obit, dep(n), pos(10), tmp;
for (int i = 0; i < m; ++i)
{
adj[a[i]][b[i]] = 1;
++cnt[a[i]];
adj[b[i]][a[i]] = 1;
++cnt[b[i]];
}
/// Find elevent and ten
for (int i = 0; i < n; ++i)
if (cnt[i] == n - 1)
{
for (int j = 0; j < n; ++j)
if (i != j && !adj[i][j] && cnt[j] == n - 12)
{
ten = j;
elv = i;
break;
}
if (ten != -1)
break;
}
/// find bit
auto bfs = [&](int v) {
fill(dep.begin(), dep.end(), 0);
dep[v] = 1;
queue<int> q;
q.emplace(v);
while (q.size())
{
int c = q.front();
q.pop();
pos[dep[c] - 1] = c;
for (auto i : obit)
if (!dep[i] && adj[c][i])
{
++son[c];
dep[i] = dep[v] + 1;
}
}
};
for (int i = 0; i < n; ++i)
if (i != elv && !adj[ten][i])
obit.emplace_back(i);
bfs(obit[0]);
for (auto i : obit)
if (son[i] == 0)
tmp.emplace_back(i);
if (tmp.size() == 1)
bfs(cnt[tmp.back()] > cnt[obit[0]] ? tmp.back() : obit[0]);
else
bfs(cnt[tmp[0]] > cnt[tmp[1]] ? tmp[0] : tmp[1]);
for (int i = 0; i < 10; ++i)
for (int j = 0; j < n; ++j)
if (adj[pos[i]][j])
real[j] |= 1 << i;
for (int i = 0; i < n; ++i)
if (adj[ten][i])
for (int j = i + 1; j < n; ++j)
if (adj[ten][j])
s.emplace_back(real[i], real[j]);
InitG(n - 12, s.size());
for (auto i : s)
MakeG(i.first, i.second);
}