#5230. Unvarnished Report

0
    ID: 5230 传统题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>AtCoderabc374BGESP 3级字符串枚举(单层循环)

Unvarnished Report

Unvarnished Report

题目描述

KEYENCE 有一种如实报告事物的文化,无论好坏。
所以我们想检查所报告的内容是否与原文完全相同。
You are given two strings $S$ and $T$, consisting of lowercase English letters.
If $S$ and $T$ are equal, print $0$; otherwise, print the position of the first character where they differ.
Here, if the $i$-th character exists in only one of $S$ and $T$, consider that the $i$-th characters are different. More precisely, if $S$ and $T$ are not equal, print the smallest integer $i$ satisfying one of the following conditions:

1≤i≤∣S∣1\leq i\leq |S|, 1≤i≤∣T∣1\leq i\leq |T|, and Si≠TiS_i\neq T_i. |S| < i \leq |T|. |T| < i \leq |S|.

Here, ∣S∣|S| and ∣T∣|T| denote the lengths of SS and TT, respectively, and SiS_i and TiT_i denote the ii-th characters of SS and TT, respectively.

输入格式

The input is given from Standard Input in the following format: SS TT

输出格式

If SS and TT are equal, print 00; otherwise, print the position of the first character where they differ.

abcde
abedc
3
abcde
abcdefg
6
keyence
keyence
0

提示

SS and TT are strings of length between 11 and 100100, inclusive, consisting of lowercase English letters.We have S=S= abcdeabcde and T=T= abedcabedc.
SS and TT have the same first and second characters, but differ at the third character, so print 33.
We have S=S= abcdeabcde and T=T= abcdefgabcdefg.
SS and TT are equal up to the fifth character, but only TT has a sixth character, so print 66.
SS and TT are equal, so print 00.

标签: AtCoder|abc374B

来源

AtCoder|abc374B