CF1886C.Decreasing String
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Recall that string a is lexicographically smaller than string b if a is a prefix of b (and a=b), or there exists an index i (1≤i≤min(∣a∣,∣b∣)) such that ai<bi, and for any index j (1≤j<i) aj=bj.
Consider a sequence of strings s1,s2,…,sn, each consisting of lowercase Latin letters. String s1 is given explicitly, and all other strings are generated according to the following rule: to obtain the string si, a character is removed from string si−1 in such a way that string si is lexicographically minimal.
For example, if s1=dacb, then string s2=acb, string s3=ab, string s4=a.
After that, we obtain the string S=s1+s2+⋯+sn (S is the concatenation of all strings s1,s2,…,sn).
You need to output the character in position pos of the string S (i. e. the character Spos).
回忆一下,若字符串 a 是字符串 b 的前缀(且 a=b),或存在某个下标 i(满足 1≤i≤min(∣a∣,∣b∣)),使得 ai<bi,且对任意下标 j(满足 1≤j<i)都有 aj=bj,则称字符串 a 在字典序上小于字符串 b。
考虑一个由小写拉丁字母组成的字符串序列 s1,s2,…,sn。其中字符串 s1 被显式给出,其余所有字符串均按如下规则生成:为得到字符串 si,需从字符串 si−1 中删去一个字符,使得 si 的字典序最小。
例如,若 s1=dacb,则 s2=acb,s3=ab,s4=a。
随后,我们构造字符串 S=s1+s2+⋯+sn(即 S 是所有字符串 s1,s2,…,sn 的拼接)。
你需要输出字符串 S 中位置为 pos 的字符(即字符 Spos)。
输入格式
The first line contains one integer t — the number of test cases (1≤t≤104).
Each test case consists of two lines. The first line contains the string s1 (1≤∣s1∣≤106), consisting of lowercase Latin letters. The second line contains the integer pos (1≤pos≤2∣s1∣⋅(∣s1∣+1)). You may assume that n is equal to the length of the given string (n=∣s1∣).
Additional constraint on the input: the sum of ∣s1∣ over all test cases does not exceed 106.
第一行包含一个整数 t —— 测试用例的数量(1≤t≤104)。
每个测试用例由两行组成。第一行包含字符串 s1(1≤∣s1∣≤106),该字符串仅由小写拉丁字母组成;第二行包含整数 pos(1≤pos≤2∣s1∣⋅(∣s1∣+1))。你可以假设 n 等于给定字符串的长度(即 n=∣s1∣)。
输入的额外约束:所有测试用例中 ∣s1∣ 的总和不超过 106。
输出格式
For each test case, print the answer — the character that is at position pos in string S. Note that the answers between different test cases are not separated by spaces or line breaks.
对于每个测试用例,输出答案——即字符串 S 中位置为 pos 的字符。注意:不同测试用例的答案之间不以空格或换行符分隔。
输入输出样例
输入#1
3 cab 6 abcd 9 x 1
输出#1
abx
输入解题思路,AI测评打分。不知道怎么写?