There are nn left boots and nn right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark (’?’). Thus, you are given two strings ll and rr, both of length nn. The character lili stands for the color of the ii-th left boot and the character riri stands for the color of the ii-th right boot.A lowercase Latin letter denotes a specific color, but the question mark (’?’) denotes an indefinite color. Two specific colors are compatible if they are exactly the same. An indefinite color is compatible with any (specific or indefinite) color.For example, the following pairs of colors are compatible: (‘f’, ‘f’), (’?’, ‘z’), (‘a’, ‘?’) and (’?’, ‘?’). The following pairs of colors are not compatible: (‘f’, ‘g’) and (‘a’, ‘z’).Compute the maximum number of pairs of boots such that there is one left and one right boot in a pair and their colors are compatible.Print the maximum number of such pairs and the pairs themselves. A boot can be part of at most one pair.
输入
The first line contains nn (1≤n≤1500001≤n≤150000), denoting the number of boots for each leg (i.e. the number of left boots and the number of right boots).The second line contains the string ll of length nn. It contains only lowercase Latin letters or question marks. The ii-th character stands for the color of the ii-th left boot.The third line contains the string rr of length nn. It contains only lowercase Latin letters or question marks. The ii-th character stands for the color of the ii-th right boot.
输出
Print kk — the maximum number of compatible left-right pairs of boots, i.e. pairs consisting of one left and one right boot which have compatible colors.The following kk lines should contain pairs aj,bjaj,bj (1≤aj,bj≤n1≤aj,bj≤n). The jj-th of these lines should contain the index ajaj of the left boot in the jj-th pair and index bjbj of the right boot in the jj-th pair. All the numbers ajaj should be distinct (unique), all the numbers bjbj should be distinct (unique).If there are many optimal answers, print any of them.
具体就是用int 型队列 l [ t - ‘a’ ] , r [ t - ‘a’ ] 保存第一个串各个字母字符的位置,将?的位置保存在队列 lw 中。再输入第二个串中的字符,如果 l [ t - ’ a ’ ] 不为空说明 1串中有可以匹配的值,将两个字符对应位置保存在数组 b[ ] 中,保存后就将他们都从对应的队列中弹出,记录匹配数量的值 ans ++。