Not Another Constructive!

시간 제한1초메모리 제한2048 MB

요약
길이 n 문자열에서 일부 글자는 고정되어 있고 물음표를 채워 부분수열 NAC의 개수가 정확히 k가 되도록 만들거나, 불가능하면 -1을 출력한다.
난이도

보통10점 중 7점

유형
동적 계획법, 그리디, 조합론, 문자열
정답자
아직 제출이 없습니다

문제

Sick of solving geometry problems, you decide to solve the following constructive problem: find a string of length nn that contains exactly kk not necessarily contiguous subsequences of NAC.

This problem seems too familiar though. Here's the twist - your friend has given you part of the string, so you must fill in the remaining characters!

입력

The first line of input contains two integers nn (1≤n≤401 \le n \le 40) and kk (0≤k≤2,5000 \le k \le 2\\,500), where nn is the length of the string and kk is the number of not necessarily contiguous subsequences of NAC that the output must contain.

The second line contains a string of length exactly nn, consisting only of uppercase letters and/or question marks.

출력

Output a string of upper case letters, replacing each question mark in the input string with an uppercase letter so that the resulting string has exactly kk subsequences of NAC. If this is not possible, output -1. Any uppercase letters in the input string must be kept in their position. There may be multiple possible solutions for any given test case; any correct solution will be accepted.

예제3

  1. 예제 1

    입력
    22 2
    N??A??????C???????????
    
    예상 출력
    NOTANOTHERCONSTRUCTIVE
    
  2. 예제 2

    입력
    18 0
    COUNTINGSATELLITES
    
    예상 출력
    COUNTINGSATELLITES
    
  3. 예제 3

    입력
    2 1
    ??
    
    예상 출력
    -1