103511: [Atcoder]ABC351 B - Spot the Difference
Description
Score: $150$ points
Problem Statement
You are given two grids, each with $N$ rows and $N$ columns, referred to as grid $A$ and grid $B$.
Each cell in the grids contains a lowercase English letter.
The character at the $i$-th row and $j$-th column of grid $A$ is $A_{i, j}$.
The character at the $i$-th row and $j$-th column of grid $B$ is $B_{i, j}$.
The two grids differ in exactly one cell. That is, there exists exactly one pair $(i, j)$ of positive integers not greater than $N$ such that $A_{i, j} \neq B_{i, j}$. Find this $(i, j)$.
Constraints
- $1 \leq N \leq 100$
- $A_{i, j}$ and $B_{i, j}$ are all lowercase English letters.
- There exists exactly one pair $(i, j)$ such that $A_{i, j} \neq B_{i, j}$.
Input
The input is given from Standard Input in the following format:
$N$ $A_{1,1}A_{1,2}\dots A_{1,N}$ $A_{2,1}A_{2,2}\dots A_{2,N}$ $\vdots$ $A_{N,1}A_{N,2}\dots A_{N,N}$ $B_{1,1}B_{1,2}\dots B_{1,N}$ $B_{2,1}B_{2,2}\dots B_{2,N}$ $\vdots$ $B_{N,1}B_{N,2}\dots B_{N,N}$
Output
Let $(i, j)$ be the pair of positive integers not greater than $N$ such that $A_{i, j} \neq B_{i, j}$. Print $(i, j)$ in the following format:
$i$ $j$
Sample Input 1
3 abc def ghi abc bef ghi
Sample Output 1
2 1
From $A_{2, 1} =$ d
and $B_{2, 1} =$ b
, we have $A_{2, 1} \neq B_{2, 1}$, so $(i, j) = (2, 1)$ satisfies the condition in the problem statement.
Sample Input 2
1 f q
Sample Output 2
1 1
Sample Input 3
10 eixfumagit vtophbepfe pxbfgsqcug ugpugtsxzq bvfhxyehfk uqyfwtmglr jaitenfqiq acwvufpfvv jhaddglpva aacxsyqvoj eixfumagit vtophbepfe pxbfgsqcug ugpugtsxzq bvfhxyehok uqyfwtmglr jaitenfqiq acwvufpfvv jhaddglpva aacxsyqvoj
Sample Output 3
5 9
Output
问题描述
你被给出了两个网格,每个都有 $N$ 行和 $N$ 列,分别称为网格 $A$ 和网格 $B$。
每个网格的单元格内包含一个英文字母小写字符。
网格 $A$ 的第 $i$ 行第 $j$ 列的字符是 $A_{i, j}$。
网格 $B$ 的第 $i$ 行第 $j$ 列的字符是 $B_{i, j}$。
这两个网格在恰好一个单元格上不同。也就是说,存在一个唯一的正整数对 $(i, j)$,其值不大于 $N$,满足 $A_{i, j} \neq B_{i, j}$。找到这个 $(i, j)$。
约束条件
- $1 \leq N \leq 100$
- $A_{i, j}$ 和 $B_{i, j}$ 都是小写英文字母。
- 存在且仅存在一对 $(i, j)$ 使得 $A_{i, j} \neq B_{i, j}$。
输入
输入将以以下格式从标准输入给出:
$N$ $A_{1,1}A_{1,2}\dots A_{1,N}$ $A_{2,1}A_{2,2}\dots A_{2,N}$ $\vdots$ $A_{N,1}A_{N,2}\dots A_{N,N}$ $B_{1,1}B_{1,2}\dots B_{1,N}$ $B_{2,1}B_{2,2}\dots B_{2,N}$ $\vdots$ $B_{N,1}B_{N,2}\dots B_{N,N}$
输出
令 $(i, j)$ 为一对不大于 $N$ 的正整数,满足 $A_{i, j} \neq B_{i, j}$。以如下格式输出 $(i, j)$:
$i$ $j$
样例输入1
3 abc def ghi abc bef ghi
样例输出1
2 1
从 $A_{2, 1} =$ d
和 $B_{2, 1} =$ b
可知,$A_{2, 1} \neq B_{2, 1}$,所以 $(i, j) = (2, 1)$ 满足题目描述中的条件。
样例输入2
1 f q
样例输出2
1 1
样例输入3
10 eixfumagit vtophbepfe pxbfgsqcug ugpugtsxzq bvfhxyehfk uqyfwtmglr jaitenfqiq acwvufpfvv jhaddglpva aacxsyqvoj eixfumagit vtophbepfe pxbfgsqcug ugpugtsxzq bvfhxyehok uqyfwtmglr jaitenfqiq acwvufpfvv jhaddglpva aacxsyqvoj
样例输出3
5 9