Submission #1301054


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[1000][1000];
bool ok[1000][1000];
void func(int h, int w, int k)
{
	if (h < 0 || H <= h || w < 0 || W <= w) { return; }
	if (k < 0) { return; }
	if (ok[h][w]) { return; }
	if (map[h][w] == '#') { return; }
	ok[h][w] = true;
	func(h - 1, w, k - 1);
	func(h - 1, w, k - 1);
	func(h, w - 1, k - 1);
	func(h, w + 1, k - 1);
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> H>>W>>K;
	for (size_t i = 0; i < H; i++)
	{
		in >> map[i];
	}
	int sx, sy;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t w = 0; w < W; w++)
		{
			if (map[i][w] == 'S') {
				sx = w; sy = i; map[i][w] = '.';
			}
		}
	}
	func(sy, sx, K);

	int res = H*W;
	for (int i = 0; i < H; i++)
	{
		for (int w = 0; w < W; w++)
		{
			if (ok[i][w]) {
				res = std::min(res, 1 + (std::min({ i,H - i - 1,w,W - w - 1 })+K-1)/K);
			}
		}
	}
	std::cout << res << 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 1420 Byte
Status WA
Exec Time 13 ms
Memory 1664 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 3
AC × 38
WA × 8
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 WA 3 ms 1024 KB
in10.txt WA 3 ms 1024 KB
in11.txt AC 3 ms 1024 KB
in12.txt AC 3 ms 1024 KB
in13.txt AC 3 ms 1024 KB
in14.txt AC 3 ms 1024 KB
in15.txt AC 3 ms 1024 KB
in16.txt AC 3 ms 1024 KB
in17.txt AC 3 ms 1024 KB
in18.txt AC 3 ms 1024 KB
in19.txt AC 3 ms 1024 KB
in2.txt AC 3 ms 1024 KB
in20.txt AC 2 ms 1024 KB
in21.txt AC 1 ms 256 KB
in22.txt AC 1 ms 256 KB
in23.txt AC 3 ms 1024 KB
in24.txt AC 3 ms 1024 KB
in25.txt AC 3 ms 1024 KB
in26.txt WA 3 ms 1152 KB
in27.txt AC 3 ms 1024 KB
in28.txt WA 4 ms 1280 KB
in29.txt AC 6 ms 1664 KB
in3.txt WA 3 ms 1024 KB
in30.txt AC 4 ms 1152 KB
in31.txt WA 3 ms 1024 KB
in32.txt AC 3 ms 1024 KB
in33.txt AC 13 ms 1664 KB
in34.txt AC 11 ms 1536 KB
in35.txt AC 3 ms 1024 KB
in36.txt AC 3 ms 1024 KB
in37.txt AC 3 ms 1024 KB
in38.txt AC 3 ms 1024 KB
in39.txt WA 3 ms 1024 KB
in4.txt AC 3 ms 1024 KB
in40.txt WA 3 ms 1024 KB
in5.txt AC 3 ms 1024 KB
in6.txt AC 3 ms 1024 KB
in7.txt AC 3 ms 1024 KB
in8.txt AC 3 ms 1024 KB
in9.txt AC 3 ms 1024 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB