Created
July 7, 2021 15:46
-
-
Save uchidama/00577ea39afed26a2d7f28dd1057f201 to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 177 [ B - Substring ] https://atcoder.jp/contests/abc177/tasks/abc177_b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
[問題] | |
https://atcoder.jp/contests/abc177/tasks/abc177_b | |
[解説] | |
https://atcoder.jp/contests/abc177/editorial/87 | |
''' | |
import sys | |
sys.setrecursionlimit(10 ** 6) # 再帰上限の引き上げ | |
input = sys.stdin.readline | |
INF = 2 ** 63 - 1 | |
S = input() | |
S = S.replace( '\n' , '' ) | |
T = input() | |
T = T.replace( '\n' , '' ) | |
ans = len(T) | |
# SとTを総当たりで見ていって、何文字違うかカウントする。その最小値が答え | |
for S_START in range(0, len(S) - len(T) + 1): | |
diff = 0 | |
for i in range(0, len(T)): | |
if S[S_START + i] != T[i]: | |
diff += 1 | |
ans = min(ans, diff) | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment