Problem 2968 --String

2968: String

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $2$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Tom has a string containing only lowercase letters. He wants to choose a subsequence of the string whose length is kk and lexicographical order is the smallest. It's simple and he solved it with ease. 
But Jerry, who likes to play with Tom, tells him that if he is able to find a lexicographically smallest subsequence satisfying following 26 constraints, he will not cause Tom trouble any more. 
The constraints are: the number of occurrences of the iith letter from a to z (indexed from 11 to 2626) must in [Li,Ri][Li,Ri]
Tom gets dizzy, so he asks you for help.
The input contains multiple test cases. Process until the end of file. 
Each test case starts with a single line containing a string S(|S|≤105)S(|S|≤105)and an integer k(1≤k≤|S|)k(1≤k≤|S|)
Then 2626 lines follow, each line two numbers Li,Ri(0≤Li≤Ri≤|S|)Li,Ri(0≤Li≤Ri≤|S|)
It's guaranteed that SS consists of only lowercase letters, and ∑|S|≤3×105∑|S|≤3×105
Output the answer string. 
If it doesn't exist, output −1−1.
aaabbb 3
0 3
2 3
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
abb

推荐代码 查看2968 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$10 $ms] 刘成健 460914 2019-09-04 20:45:51
内存最少[$12916 $KB] 刘成健 460914 2019-09-04 20:45:51
第一AC 刘成健 460914 2019-09-04 20:45:51
第一挑战 刘成健 460914 2019-09-04 20:45:51

赛题来源/所属竞赛 2019 Multi-University Training Contest 1 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛