Submission #791869

# Submission time Handle Problem Language Result Execution time Memory
791869 2023-07-24T11:59:16 Z Boomyday Bitaro the Brave (JOI19_ho_t1) PyPy 3
0 / 100
51 ms 20108 KB
H, W = map(int, input().split())

grid = []

for i in range(H):
    st = list(input())
    for j in range(W):
        if st[j] == "J":
            st[j] = 0
        elif st[j] == "O":
            st[j] = 1
        elif st[j] == "I":
            st[j] = 2


## grid[h][w]

grido = [[0 for i in range(W+1)] for j in range(H+1)] ## rows
gridi = [[0 for i in range(W+1)] for j in range(H+1)] ## cols



## o

for row in range(H):
    for col in range(W-1, -1, -1):

        num = (grid[row][col] == 1)
        grido[row][col] = grido[row][col+1] + num

## i
for col in range(W):
    for row in range(H-1, -1, -1):
        num = (grid[row][col] == 2)
        gridi[row][col] = gridi[row+1][col] + num

ans = 0

for row in range(H):
    for col in range(W):
        if grid[row][col] == 0:
            ans += grido[row][col+1] * gridi[row+1][col]

print(ans)
# Verdict Execution time Memory Grader output
1 Runtime error 51 ms 20108 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 51 ms 20108 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 51 ms 20108 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -