Submission #1251476

#TimeUsernameProblemLanguageResultExecution timeMemory
1251476jwvg0425World Map (IOI25_worldmap)C++20
0 / 100
11 ms1604 KiB
#include "worldmap.h"
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

template<typename T, typename Pr = less<T>>
using pq = priority_queue<T, vector<T>, Pr>;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

vector<int> edges[45];
bool visited[45];
vector<vector<int>> ans;

void cover(int root, int& x, int& y, int& w, int& h)
{
	for (int i = x; i < x + w; i++)
	{
		ans[i][y] = root;
		ans[i][y + h - 1] = root;
	}

	for (int j = y; j < y + h; j++)
	{
		ans[x][j] = root;
		ans[x + w - 1][j] = root;
	}

	x += 1;
	y += 1;
	w -= 2;
	h -= 2;
}

void dfs(int root, int& x, int& y, int& w, int& h)
{
	cover(root, x, y, w, h);
	visited[root] = true;

	for (auto& c : edges[root])
	{
		if (visited[c])
			continue;

		dfs(c, x, y, w, h);
		cover(root, x, y, w, h);
	}
}

vector<vector<int>> create_map(int N, int M, vector<int> A, vector<int> B) {
	for (int i = 0; i < N; i++)
		edges[i].clear();

	memset(visited, false, sizeof(visited));

	for (int i = 0; i < M; i++)
	{
		edges[A[i]].push_back(B[i]);
		edges[B[i]].push_back(A[i]);
	}

	ans.clear();
	ans.resize(N * 6, vector<int>(N * 6));
	int x = 0, y = 0, w = N * 6, h = N * 6;
	dfs(1, x, y, w, h);

	for (int i = x; i < x + w; i++)
		for (int j = y; j < y + h; j++)
			ans[i][j] = 1;

	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...