#include "worldmap.h"
#define pb push_back
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int n, m;
vector < int > g[maxn];
int col[maxn];
vector < int > path;
void dfs(int beg, int from)
{
path.pb(beg);
for(auto nb: g[beg])
{
if(nb == from)continue;
dfs(nb, beg);
path.pb(beg);
}
}
std::vector<std::vector<int>> create_map(int N, int M, std::vector<int> A, std::vector<int> B)
{
assert(M >= N-1);
n = N;
m = M;
path.clear();
for (int i = 0; i <= 2*n; ++ i)
g[i].clear();
for (int i = 0; i < m; ++ i)
{
g[A[i]].pb(B[i]);
g[B[i]].pb(A[i]);
}
dfs(1, 0);
int szp = path.size();
std::vector<std::vector<int>> ans(szp, std::vector<int>(szp, 0));
for (int j = 0; j < szp; ++ j)
ans[0][j] = path[j];
for (int i = 1 ; i < szp; ++ i)
{
for(int j = 0; j < szp; ++ j)
ans[i][j] = ans[i-1][j];
}
return ans;
for (int i = 0; i < 2*n; ++ i)
{
if(col[i] == 1)
{
for (int j = 0; j < 2*n; ++ j)
ans[i][j] = 1;
}
else
{
int v = col[i];
int j = 0;
for (auto x: g[v])
{
ans[i][j] = x;
j ++;
ans[i][j] = v;
j ++;
}
while(j < 2*n)
{
ans[i][j] = v;
j ++;
}
}
}
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... |