2026年10月9日

2 道题返回最新一期
C
Common Subsequence
GYM102307C
1600GYM4 s256 megabytes
Codeforces

C. 公共子序列AI (CI翻译)(GPT 5.6 Terra)

题目描述

Manuel thinks that Diego is his long lost brother. But Diego thinks Manuel is wrong, and to prove it, he got DNA samples from himself and Manuel. Now Diego has given you the DNA samples and it is your task to say whether they are brothers or not.

Manuel 认为 Diego 是他失散多年的兄弟。但 Diego 认为 Manuel 错了,为了证明这一点,他获取了自己和 Manuel 的 DNA 样本。现在 Diego 把 DNA 样本交给了你,你的任务是判断他们是否是兄弟。AI (CI翻译)(GPT 5.6 Terra)

The DNA samples of Diego and Manuel are strings $A$ and $B$, both have length $n$ ($1 \leq n \leq 10^5$) and consist of only the characters 'A', 'T', 'G' and 'C'. If there is a common subsequence of $A$ and $B$ that has length greater than or equal to $0.99 \times n$, then Diego and Manuel are brothers, in other case, they are not.

Diego 和 Manuel 的 DNA 样本分别是字符串 $A$ 和 $B$,长度均为 $n$($1 \leq n \leq 10^5$),且仅由字符 'A'、'T'、'G' 和 'C' 组成。如果 $A$ 和 $B$ 存在一个长度大于或等于 $0.99 \times n$ 的公共子序列,那么 Diego 和 Manuel 就是兄弟;否则,他们不是兄弟。AI (CI翻译)(GPT 5.6 Terra)

输入格式

The input consists of two lines with strings $A$ and $B$, respectively.

输入包含两行,分别为字符串 $A$ 和 $B$。AI (CI翻译)(GPT 5.6 Terra)

输出格式

You should output a single line with "Long lost brothers D:" (without quotes) if Diego and Manuel are brothers, and "Not brothers :(" (without quotes) if they are not.

如果 Diego 和 Manuel 是兄弟,则应输出一行“Long lost brothers D:”(不含引号);如果他们不是兄弟,则输出“Not brothers :(”(不含引号)。AI (CI翻译)(GPT 5.6 Terra)

备注

A subsequence of a string $X$ is any string that you can get by removing any number of characters from $X$.

字符串 $X$ 的一个子序列是可以通过从 $X$ 中删除任意数量的字符得到的任意字符串。AI (CI翻译)(GPT 5.6 Terra)

A common subsequence of strings $X$ and $Y$ is a string that is a subsequence of both $X$ and $Y$.

字符串 $X$ 和 $Y$ 的公共子序列,是同时为 $X$ 和 $Y$ 的子序列的字符串。AI (CI翻译)(GPT 5.6 Terra)

样例

样例 1

Input
GAATTGCGTACAATGC
GAATTGCGTACAATGC
Output
Long lost brothers D:

样例 2

Input
CCATAGAGAA
CGATAGAGAA
Output
Not brothers :(

A
Andrew and Efficient Change
GYM102319A
1800GYM2 s256 megabytes
Codeforces

A. Andrew 与高效找零AI (CI翻译)(GPT 5.6 Terra)

题目描述

The kid Andrew doesn't like coins. His country currently uses n different coin types, each with a different value. It is guaranteed that the coin with value 1 is one of the different coin types.

小孩 Andrew 不喜欢硬币。他的国家目前使用 n 种不同的硬币,每种硬币的面值都不同。保证面值为 1 的硬币属于这 n 种不同的硬币之一。AI (CI翻译)(GPT 5.6 Terra)

Andrew's weekly taco-pizza grocery list contains r - l + 1 items with costs l, l + 1, ..., r. Unfortunately, Andrew needs to buy each of these items separately as they are sold at different stores. Furthermore, these stores do not give any change, so Andrew must pay the exact amount in coins. Andrew is rather unhappy with the amount of coins he needs to handle every week, so he wants to convince his country to start using a new coin type to minimize the total number of coins needed to buy groceries for his weekly taco-pizza needs.

Andrew 每周购买塔可披萨所需的购物清单包含 r - l + 1 件商品,它们的价格分别为 l、l + 1、...、r。不幸的是,由于这些商品在不同的商店出售,Andrew 需要分别购买每一件商品。此外,这些商店不找零,因此 Andrew 必须用硬币支付恰好对应的金额。Andrew 对每周需要处理的硬币数量相当不满,因此他希望说服他的国家开始使用一种新的硬币面值,以最小化购买每周所需塔可披萨用品时所需的硬币总数。AI (CI翻译)(GPT 5.6 Terra)

Andrew is too busy infiltrating UBC, so he wants you to tell him the best coin type to add, or that no new coin types can decrease the amount of coins he needs to use.

Andrew 正忙于潜入 UBC,因此他希望你告诉他应该添加的最佳硬币面值,或者告诉他不存在能够减少所需硬币数量的新硬币面值。AI (CI翻译)(GPT 5.6 Terra)

输入格式

The first line of the input will include an integer n (1 ≤ n ≤ 420), the number of coin types available.

输入的第一行包含一个整数 n(1 ≤ n ≤ 420),表示可用的硬币种类数。AI (CI翻译)(GPT 5.6 Terra)

The next line will include two integers l and r (1 ≤ l ≤ r ≤ 200000, r - l ≤ 50), the range of costs for Andrew's grocery list.

接下来一行包含两个整数 l 和 r(1 ≤ l ≤ r ≤ 200000,r - l ≤ 50),表示 Andrew 购物清单中商品价格的范围。AI (CI翻译)(GPT 5.6 Terra)

The next line will include n integers ci (1 ≤ ci ≤ 200000), the value of each coin type that is currently being used. It is guaranteed that no ci is repeated, and there will be some i such that ci = 1.

接下来一行包含 n 个整数 c_i(1 ≤ c_i ≤ 200000),表示当前使用的每种硬币的面值。保证不存在重复的 c_i,并且存在某个 i 使得 c_i = 1。AI (CI翻译)(GPT 5.6 Terra)

输出格式

The output should contain a single integer. If no new coin type can decrease the total number of coins used, print 0. Otherwise, print a single integer 1 ≤ c ≤ r, the value of the coin type which, when added to the coin system, minimizes the total number of coins Andrew uses. If there are multiple solutions, output any.

输出应包含一个整数。如果没有新增硬币面值能够减少所使用的硬币总数,则输出 0。否则,输出一个整数 1 ≤ c ≤ r,表示加入硬币系统后能够使 Andrew 使用的硬币总数最少的硬币面值。如果有多个解,输出任意一个即可。AI (CI翻译)(GPT 5.6 Terra)

样例

样例 1

Input
1
10 10
1
Output
10

样例 2

Input
3
10 15
1 5 10
Output
12