Submission #1301039


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; }
	ok[h][w] = true;
	func(h - 1, w - 1, k - 1);
	func(h - 1, w + 1, k - 1);
	func(h + 1, w - 1, k - 1);
	func(h + 1, 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(sx, sy, K);

	int res = H*W;
	for (int i = 0; i < H; i++)
	{
		for (int w = 0; w < W; w++)
		{
			if (map[i][w] != '#' && 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 18 ms
Memory 14080 KB

Judge Result

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