Submission #1301068


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=0, sy = 0;
	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] = '.';
				goto end;
			}
		}
	}
end:
	if (sx == 0 || sy == 0) { throw 0; }
	for (size_t i = 0; i < H; i++)
	{
		if (std::any_of(map[i], map[i] + W, [](char c) {return c != '#'&&c != '.'; })) {
			throw 0;
		}
	}
	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

#if 0
#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;

template<size_t B,size_t NUM>
struct fib {
	enum { value = fib<B, NUM/2>::value + fib<B + NUM / 2, NUM/2>::value };
};
template<size_t B>
struct fib<B, 1> {
	enum { value = 0 };
};
template<size_t N>
struct fib_ :fib<0, N> {
};

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	if (fib_<0xffffffff>::value < 9999) {
		std::cout << "Hello, world!" << 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 2540 Byte
Status WA
Exec Time 39 ms
Memory 33024 KB

Judge Result

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