Logo
(追記) (追記ここまで)

20790번 - Choose Two Subsequences 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB73350.000%

문제

Clara has two strings $s$ and $t$. She would like to choose two subsequences $x$ from $s$ and $y$ from $t$ such that:

  • $x$ is lexicographically smaller than or equal to $y$.
  • The sum of $|x|$ and $|y|$ is maximal, where $|s|$ denotes the length of the string $s$.

Note that:

  • Both $x$ and $y$ could be empty string.
  • A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.
  • String $x$ is lexicographically less than string $y,ドル if either $x$ is a prefix of $y$ (and $x \ne y$), or there exists such $i$ (1ドル \le i \le \min(|x|, |y|)$), that $x_i < y_i,ドル and for any $j$ (1ドル \le j < i$) $x_j = y_j$.

입력

The input consists of several test cases terminated by end-of-file. For each test case:

The first line contains a string $s$. The second line contains a string $t$.

출력

For each test case, output the sum of $|x|$ and $|y|$.

제한

  • 1ドル \le |s| \le 2000$
  • 1ドル \le |t| \le 2000$
  • The sum of $|s|$ does not exceed 20000ドル$.
  • The sum of $|t|$ does not exceed 20000ドル$.
  • Both the strings consist only of English lowercase letters.

예제 입력 1

aaaa
bbbb
abcd
abca
abcd
abcd

예제 출력 1

8
7
8

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 6: Grand Prix of NorthBeach (Bei Sha Tan), Division 1 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /