Submission #1265084


Source Code Expand

Copy
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t H,W,K;
char MAP[810][810];
int32_t D[810][810];

template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
int32_t D_min = 800 * 800 * 800;
void func(int x, int y, int k)
{
	if (x < 0 || y < 0 || x >= W || y >= H) { return; }
	if (D[y][x] != -1) { return; }
	if (k < 0) { return; }
	if (MAP[y][x] == '#') { return; }
	D[y][x] = std::min(std::min(y, H - y - 1), std::min(x, W - x - 1));
	D_min = std::min(D_min, D[y][x]);
	func(x - 1, y, k - 1);
	func(x + 1, y, k - 1);
	func(x, y - 1, k - 1);
	func(x, y + 1, k - 1);
}
int main()
{
	fill_all(D, -1);
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> H>>W>>K;
	for (int32_t i = 0; i < H; ++i)
	{
		in >> MAP[i];
	}


	for (int32_t h = 0; h < H; ++h)for (int32_t w = 0; w < W; ++w)
	{
		if (MAP[h][w] == 'S') {
			func(h, w, K);
			break;
		}
	}
	std::cout << 1 + (D_min / K) + ((D_min%K > 0) ? 1 : 0) << std::endl;

	return 0;
}
#endif

Submission Info

Submission Time
Task C - Closed Rooms
User eiya
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1545 Byte
Status
Exec Time 31 ms
Memory 28288 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 0 / 700 sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, in39.txt, in4.txt, in40.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
in1.txt 4 ms 3456 KB
in10.txt 4 ms 3456 KB
in11.txt 4 ms 3456 KB
in12.txt 4 ms 3456 KB
in13.txt 4 ms 3456 KB
in14.txt 4 ms 3456 KB
in15.txt 4 ms 3456 KB
in16.txt 4 ms 3456 KB
in17.txt 4 ms 3456 KB
in18.txt 4 ms 3456 KB
in19.txt 4 ms 3456 KB
in2.txt 4 ms 3456 KB
in20.txt 3 ms 3456 KB
in21.txt 2 ms 2816 KB
in22.txt 2 ms 2816 KB
in23.txt 4 ms 3456 KB
in24.txt 4 ms 3456 KB
in25.txt 4 ms 3456 KB
in26.txt 4 ms 3456 KB
in27.txt 4 ms 3456 KB
in28.txt 4 ms 3456 KB
in29.txt 5 ms 3456 KB
in3.txt 4 ms 3456 KB
in30.txt 4 ms 3456 KB
in31.txt 4 ms 3456 KB
in32.txt 4 ms 3456 KB
in33.txt 31 ms 28288 KB
in34.txt 22 ms 9728 KB
in35.txt 4 ms 3456 KB
in36.txt 4 ms 3456 KB
in37.txt 4 ms 3456 KB
in38.txt 4 ms 3456 KB
in39.txt 4 ms 3456 KB
in4.txt 4 ms 3456 KB
in40.txt 4 ms 3456 KB
in5.txt 4 ms 3456 KB
in6.txt 4 ms 3456 KB
in7.txt 4 ms 3456 KB
in8.txt 4 ms 3456 KB
in9.txt 4 ms 3456 KB
sample1.txt 2 ms 2816 KB
sample2.txt 2 ms 2816 KB
sample3.txt 2 ms 2816 KB