結果

問題 No.157 2つの空洞
コンテスト
ユーザー tatt61880
提出日時 2021-03-21 11:35:55
言語 Kuin
(KuinC++ v.2021.9.17)
コンパイル:
kuinc -i _filename_ -o out.cpp -s /kuin/sys/ -e cpp -r -q
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,357 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,494 ms
コンパイル使用メモリ 164,940 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-05 17:07:31
合計ジャッジ時間 2,190 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
out.cpp:676:14: warning: first argument in call to 'memset' is a pointer to non-trivially copyable type 'std::shared_ptr<Array_<char16_t>>' [-Wnontrivial-memcall]
  676 |                         memset(r->B, 0, sizeof(T) * static_cast<std::size_t>(h + bufLen_<T>()));
      |                                   ^
out.cpp:688:9: note: in instantiation of function template specialization 'newArraysRec_<std::shared_ptr<Array_<std::shared_ptr<Array_<char16_t>>>>>::operator()<long>' requested here
  688 |         return newArraysRec_<T>()(std::forward<A>(a)...);
      |                ^
out.cpp:1643:11: note: in instantiation of function template specialization 'newArrays_<std::shared_ptr<Array_<std::shared_ptr<Array_<char16_t>>>>, long>' requested here
 1643 | (k_ap) = (newArrays_<type_(Array_<type_(Array_<char16_t>)>)>((k_ao)));
      |           ^
out.cpp:676:14: note: explicitly cast the pointer to silence this warning
  676 |                         memset(r->B, 0, sizeof(T) * static_cast<std::size_t>(h + bufLen_<T>()));
      |                                   ^
      |                                (void*)
1 warning generated.

ソースコード

diff #
raw source code

func main()
	var w: int :: cui@inputInt()
	var h: int :: cui@inputInt()
	var c: [][]char :: #[h][]char
	for i(0, h - 1)
		do c[i] :: cui@input()
	end for
	var ch: char :: 'a'
	for y(0, h - 1)
		for x(0, w - 1)
			if(c[y][x] = '.')
				var dx: []int :: [1, 0, -1, 0]
				var dy: []int :: [0, 1, 0, -1]
				var qu: queue<int> :: #queue<int>
				do qu.add(y * w + x)
				while loop(^qu <> 0)
					var pos: int :: qu.get()
					var cy: int :: pos / w
					var cx: int :: pos % w
					if(c[cy][cx] <> '.')
						skip loop
					end if
					do c[cy][cx] :: ch
					for i(0, 3)
						var nx: int :: cx + dx[i]
						if(nx < 0 | w <= nx)
							skip i
						end if
						var ny: int :: cy + dy[i]
						if(ny < 0 | h <= ny)
							skip i
						end if
						if(c[ny][nx] = '.')
							do qu.add(ny * w + nx)
						end if
					end for
				end while
				do ch :: 'b'
			end if
		end for
	end for
	
	var ans: int :: w + h
	for y(0, h - 1)
		for x(0, w - 1)
			if(c[y][x] = 'a')
				for dy(0, h - 1)
					var ny: int :: y + dy
					if(ny < 0 | h <= ny)
						skip dy
					end if
					for dx(-w + 1, w - 1)
						var nx: int :: x + dx
						if(nx < 0 | w <= nx)
							skip dx
						end if
						if(c[ny][nx] = 'b')
							do ans :: [ans, dx.abs() + dy.abs() - 1].min()
						end if
					end for
				end for
			end if
		end for
	end for
	do cui@print("\{ans}\n")
end func
0