Submission #1023566

#TimeUsernameProblemLanguageResultExecution timeMemory
1023566vjudge1Bitaro the Brave (JOI19_ho_t1)Cpython 3
50 / 100
1045 ms206988 KiB
n, m = map(int, input().split()) a = [[0 for _ in range(m + 1)] for _ in range(n + 1)] d1 = [[0 for _ in range(m + 1)] for _ in range(n + 1)] d2 = [[0 for _ in range(m + 1)] for _ in range(n + 1)] for i in range(1, n + 1) : s = input() for j in range(1, m + 1) : a[i][j] = 0 if s[j - 1] == 'J' else 1 if s[j - 1] == 'O' else 2 ans = 0 for i in range(n, 0, -1) : for j in range(m, 0, -1) : d1[i][j] = (a[i][j] == 1) + (0 if j == m else d1[i][j + 1]) d2[i][j] = (a[i][j] == 2) + (0 if i == n else d2[i + 1][j]) if a[i][j] == 0 : ans += d1[i][j] * d2[i][j] print(ans)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...