公式
B - Let's Get a Perfect Score 解説 by en_translator
We use a double loop to inspect all the pairs.
When determining if any of the pair satisfies the condition, it is a good idea to maintain a variable that stores whether the conditions so far are all satisfied, just as we did in ABC277-B Editorial. This way, the implementation is simplified. See also the sample code.
Sample code (Python):
n, m = map(int, input().split())
s = [input() for i in range(n)]
res = 0
for i in range(n):
for j in range(i + 1, n):
ok = True
for k in range(m):
if s[i][k] == 'x' and s[j][k] == 'x':
ok = False
if ok:
res += 1
print(res)
投稿日時:
最終更新: