#include "worldmap.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 250;
int n;
vector<int> g[N];
bool c[N];
void dfs(int x, vector<int>& v)
{
c[x] = true;
v.push_back(x);
for (int i = 0; i < g[x].size(); ++i)
{
int h = g[x][i];
if (!c[h])
{
dfs(h, v);
v.push_back(-x);
}
}
}
std::vector<std::vector<int> > create_map(int N, int M, std::vector<int> A, std::vector<int> B)
{
n = N;
for (int i = 0; i <= n + 1; ++i)
{
g[i].clear();
c[i] = false;
}
for (int i = 0; i < M; ++i)
{
int x = A[i];
int y = B[i];
g[x].push_back(y);
g[y].push_back(x);
}
vector<int> v;
dfs(1, v);
for (int x = 1; x <= n; ++x)
assert(c[x]);
vector<vector<int> > ans;
for (int i = 0; i < sz(v); ++i)
{
int x = v[i];
if (x > 0)
{
vector<int> t(2 * n, x);
ans.push_back(t);
for (int i = 0; i < g[x].size(); ++i)
t[i * 2] = g[x][i];
ans.push_back(t);
t.assign(2 * n, x);
ans.push_back(t);
}
else
{
x *= -1;
vector<int> t(2 * n, x);
ans.push_back(t);
}
}
for (int i = 0; i < sz(ans); ++i)
assert(sz(ans[i]) == sz(ans[0]));
while (sz(ans) < sz(ans[0]))
{
ans.push_back(ans.back());
}
while (sz(ans[0]) < sz(ans))
{
for (int i = 0; i < sz(ans); ++i)
ans[i].push_back(ans[i].back());
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |