提出 #33863865
ソースコード 拡げる
from select import select
import sys
import collections
import math
import itertools
sys.setrecursionlimit(50000)
deb = 0
H, W = map(int,input().split())
MAP = [ [0 for i in range(W+2)] for i in range(H+2)]
def main():
cnt = 0
for j in range(1,W+1) :
for i in range(1,H+1) :
if MAP[i][j] == 0 :
occupy((i,j))
cnt += 1
return cnt
def occupy(c):
if c[0]-1 >= 1 and c[1] - 1 >= 1 :
dx = [-1,0]
dy = [-1,0]
for d in itertools.product(dx,dy) :
x = c[0] + d[0]
y = c[1] + d[1]
MAP[x][y] = -1
if c[0]-1 >= 1 and c[1] + 1 <= W :
dx = [-1,0]
dy = [+1,0]
for d in itertools.product(dx,dy) :
x = c[0] + d[0]
y = c[1] + d[1]
MAP[x][y] = -1
if c[0]+1 <= H and c[1] - 1 >= 1 :
dx = [+1,0]
dy = [-1,0]
for d in itertools.product(dx,dy) :
x = c[0] + d[0]
y = c[1] + d[1]
MAP[x][y] = -1
if c[0]+1 <= H and c[1] + 1 <= W :
dx = [+1,0]
dy = [+1,0]
for d in itertools.product(dx,dy) :
x = c[0] + d[0]
y = c[1] + d[1]
MAP[x][y] = -1
return True
if __name__ == "__main__":
print(main())
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
2 / 2 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
corner_01.txt, corner_02.txt, corner_03.txt, corner_04.txt, corner_05.txt, corner_06.txt, corner_07.txt, corner_08.txt, large_01.txt, large_02.txt, large_03.txt, large_04.txt, max_01.txt, rand_01.txt, rand_02.txt, rand_03.txt, rand_04.txt, rand_05.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| corner_01.txt |
AC |
70 ms |
65624 KiB |
| corner_02.txt |
AC |
54 ms |
65684 KiB |
| corner_03.txt |
AC |
56 ms |
65600 KiB |
| corner_04.txt |
AC |
54 ms |
65712 KiB |
| corner_05.txt |
AC |
56 ms |
65896 KiB |
| corner_06.txt |
AC |
58 ms |
65560 KiB |
| corner_07.txt |
AC |
54 ms |
65544 KiB |
| corner_08.txt |
AC |
56 ms |
65324 KiB |
| large_01.txt |
AC |
80 ms |
74780 KiB |
| large_02.txt |
AC |
83 ms |
74588 KiB |
| large_03.txt |
AC |
81 ms |
74228 KiB |
| large_04.txt |
AC |
81 ms |
74444 KiB |
| max_01.txt |
AC |
81 ms |
74444 KiB |
| rand_01.txt |
AC |
80 ms |
74392 KiB |
| rand_02.txt |
AC |
73 ms |
73988 KiB |
| rand_03.txt |
AC |
62 ms |
71664 KiB |
| rand_04.txt |
AC |
79 ms |
74260 KiB |
| rand_05.txt |
AC |
74 ms |
74448 KiB |
| sample_01.txt |
AC |
59 ms |
65688 KiB |
| sample_02.txt |
AC |
53 ms |
65788 KiB |
| sample_03.txt |
AC |
58 ms |
65640 KiB |