This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Alicelib.h"
#include <bits/stdc++.h>
using namespace std;
void Alice(int N, int M, int *A, int *B) {
vector<array<int, 2>> E;
for (int i = 0; i < M; ++i) {
E.push_back({A[i], B[i]});
}
for (int i = 1; i <= N; ++i) {
for (int j = 0; j < 10; ++j) {
if (i >> j & 1) {
E.push_back({i - 1, N + j});
}
}
}
int nVer = N + 12;
for (int i = 0; i < N + 10; ++i) {
E.push_back({nVer - 1, i});
}
for (int i = 0; i < 10; ++i) {
E.push_back({nVer - 2, N + i});
}
for (int i = 1; i < 10; ++i) {
E.push_back({N + i - 1, N + i});
}
InitG(nVer, E.size());
for (int i = 0; i < E.size(); ++i) {
MakeG(i, E[i][0], E[i][1]);
}
}
#include "Boblib.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1011;
int deg[MAX], id[MAX];
bool spec[MAX], vis[MAX];
bitset<MAX> g[MAX];
void Bob(int N, int M, int *C, int *D) {
for (int i = 0; i < M; ++i) {
int u = C[i], v = D[i];
g[u][v] = g[v][u] = 1;
++deg[u], ++deg[v];
}
vector<int> ord(N); iota(ord.begin(), ord.end(), 0);
int V = *max_element(ord.begin(), ord.end(), [&](int i, int j) {
return deg[i] < deg[j];
});
assert(deg[V] == N - 2);
int U;
for (int i = 0; i < N; ++i) {
if (i != V && g[V][i] == 0) {
U = i;
break;
}
}
for (int i = 0; i < N; ++i) {
spec[i] = g[U][i];
}
vector<int> cands;
function<void(int)> dfs = [&](int u) {
vis[u] = 1;
cands.push_back(u);
for (int i = 0; i < N; ++i) {
if (g[u][i] && spec[i] && !vis[i]) {
dfs(i);
}
}
};
for (int i = 0; i < N; ++i) {
if (spec[i] && deg[i] == max(3, N - 521)) {
dfs(i);
break;
}
}
reverse(cands.begin(), cands.end());
fill(id, id + N, -1);
for (int i = 0; i < 10; ++i) {
for (int j = 0; j < N; ++j) {
if (g[cands[i]][j] && !spec[j] && j != V) {
id[j] = max(id[j], 0) + (1 << i);
}
}
}
vector<array<int, 2>> E;
for (int i = 0; i < N; ++i) {
if (id[i] != -1) {
for (int j = 0; j < N; ++j) {
if (g[i][j] && id[j] != -1 && i < j) {
E.push_back({id[i] - 1, id[j] - 1});
}
}
}
}
N -= 12;
InitMap(N, E.size());
for (auto [u, v] : E) {
MakeMap(u, v);
}
}
Compilation message (stderr)
Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for (int i = 0; i < E.size(); ++i) {
| ~~^~~~~~~~~~
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:24:7: warning: 'U' may be used uninitialized in this function [-Wmaybe-uninitialized]
24 | int U;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |