Problem:

A: 間違い探し

問題

縦に N マス、横に M マスある長方形の盤面 A, B が与えられます。各盤面について、それぞれのマスは白または黒で塗られています。

盤面 X の i 行 j 列目のマスの色を C(i, j, X) と表記することにします。

以下の条件を満たす整数の組 (i, j) がいくつあるか数えてください。

 1 \leq i \leq N

 1 \leq j \leq M

 C(i, j, A) \neq C(i, j, B)

入力形式

N M
A_1
...
A_N
B_1
...
B_N

A_i (1 \leq i \leq N) の j 文字目が # のときは C(i, j, A) が黒、. のときは C(i, j, A) が白であることを表します。B についても同様です。

制約

 1 \leq N, M \leq 2,000

 |A_i| = |B_i| = M

 A_i, B_i は # と . のみからなる文字列

出力形式

答えを一行に出力してください。

入力例1

2 3
..#
##.
.##
#..

出力例1

2

入力例2

7 28
............................
...#.....###...####....###..
..#.#...#...#..#...#..#...#.
.#...#..#......####...#.....
.#####..#...#..#......#...#.
.#...#...###...#.......###..
............................
............................
..###....###.....##....###..
.#...#..#...#...#.#...#...#.
...##...#...#.....#....####.
..#.....#...#.....#.......#.
.#####...###....####...###..
............................

出力例2

40



Sample input:
2 3
..#
##.
.##
#..


Sample output:
2

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

table1 = ''
table2 = ''

for i in range(2 * N):
    if i < N:
        table1 += input()
    else:
        table2 += input()
        
count = 0
for i, j in zip(table1, table2):
    if i != j:
        count+=1
print(count)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = [list(list(input())) for i in range(n)]
b = [list(list(input())) for i in range(n)]
cout = 0

for i in range(n):
    for j in range(m):
        if a[i][j] != b[i][j]:
            cout += 1
print(cout)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    N, M = LI()

    A = SR(N)
    B = SR(N)

    ans = 0

    for i in range(N):
        for j in range(M):
            if A[i][j] != B[i][j]:
                ans += 1
    print(ans)
    return


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(N)]
ans = 0
for a, b in zip(A, B):
    for aa, bb in zip(a, b):
        if aa != bb:
            ans += 1
print(ans)