#include "worldmap.h"
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define bl ' '
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define comp(v) (v).erase(unique(all(v)), (v).end())
#define lbd(v,x) lower_bound(all(v), (x))-(v).begin()
#define ubd(v,x) upper_bound(all(v), (x))-(v).begin()
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<int, pi> ipi;
typedef pair<pi, pi> pipi;
typedef pair<ll, ll> pll;
const int MAXN = 100100*5;
const ll MOD = 1e9+7;
const ll INF = 1e9+10;
vector<int> adj[44];
vector<int> v;
bool vst[44];
void dfs(int here) {
v.push_back(here); vst[here]=1;
for(int there:adj[here]) {
if(vst[there]) continue;
dfs(there); v.push_back(here);
}
}
std::vector<std::vector<int>> create_map(int N, int M, std::vector<int> A, std::vector<int> B) {
std::vector<std::vector<int>> ans(4 * N, std::vector<int>(4 * N));
for(int i=1;i<=N;i++) adj[i].clear(), vst[i]=0;
for(int i=0;i<M;i++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
v.clear(); dfs(1); assert(v.size() <= 2*N);
for(int i=1, y=2; i<v.size(); i+=2, y+=4) {
for(int x=0;x<4*N;x+=2) ans[x][y]=v[i];
for(int x=1;x<4*N;x+=2) ans[x][y-1]=v[i];
for(int x=1;x<4*N;x+=2) ans[x][y+1]=v[i];
for(int x=1, t=0;x<4*N;x+=2) {
if(t<adj[v[i]].size()) {
ans[x][y]=adj[v[i]][t]; t++;
} else ans[x][y]=v[i];
}
} for(int i=0, y=0; i<v.size(); i+=2, y+=4) {
for(int x=1;x<4*N;x+=2) ans[x][y]=v[i];
if(i>0) for(int x=0;x<4*N;x+=2) ans[x][y-1]=v[i];
if(i+1<v.size()) for(int x=0;x<4*N;x+=2) ans[x][y+1]=v[i];
for(int x=0, t=0;x<4*N;x+=2) {
if(t<adj[v[i]].size()) {
ans[x][y]=adj[v[i]][t]; t++;
} else ans[x][y]=v[i];
}
}
for(int i=0;i<4*N;i++) for(int x=0;x<4*N;x++) if(!ans[x][i]) ans[x][i]=v.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... |