Submission #1266262


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(w, h, 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 WA
Exec Time 31 ms
Memory 28416 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 3
AC × 42
WA × 4
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All 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 AC 4 ms 3456 KB
in10.txt AC 4 ms 3456 KB
in11.txt AC 4 ms 3456 KB
in12.txt AC 4 ms 3456 KB
in13.txt AC 4 ms 3456 KB
in14.txt AC 4 ms 3456 KB
in15.txt AC 4 ms 3456 KB
in16.txt AC 4 ms 3456 KB
in17.txt AC 4 ms 3456 KB
in18.txt AC 4 ms 3456 KB
in19.txt AC 4 ms 3456 KB
in2.txt AC 4 ms 3456 KB
in20.txt AC 3 ms 3456 KB
in21.txt AC 2 ms 2816 KB
in22.txt AC 2 ms 2816 KB
in23.txt AC 4 ms 3456 KB
in24.txt AC 4 ms 3456 KB
in25.txt AC 4 ms 3456 KB
in26.txt WA 4 ms 3456 KB
in27.txt AC 4 ms 3456 KB
in28.txt WA 4 ms 3456 KB
in29.txt AC 5 ms 3456 KB
in3.txt AC 4 ms 3456 KB
in30.txt WA 4 ms 3456 KB
in31.txt AC 4 ms 3456 KB
in32.txt AC 4 ms 3456 KB
in33.txt AC 31 ms 28416 KB
in34.txt AC 22 ms 9728 KB
in35.txt AC 4 ms 3456 KB
in36.txt AC 4 ms 3456 KB
in37.txt AC 4 ms 3456 KB
in38.txt AC 4 ms 3456 KB
in39.txt WA 4 ms 3456 KB
in4.txt AC 4 ms 3456 KB
in40.txt AC 4 ms 3456 KB
in5.txt AC 4 ms 3456 KB
in6.txt AC 4 ms 3456 KB
in7.txt AC 4 ms 3456 KB
in8.txt AC 4 ms 3456 KB
in9.txt AC 4 ms 3456 KB
sample1.txt AC 2 ms 2816 KB
sample2.txt AC 2 ms 2816 KB
sample3.txt AC 2 ms 2816 KB