Exploring ruins
Practice
3.5 (86 votes)
Algorithms
Approved
Easy
Greedy algorithms
Problem
94% Success 24010 Attempts 10 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Little robot CJ-17 is exploring ancient ruins. He found a piece of paper with a word written on it. Fortunately, people who used to live at this location several thousand years ago used only two letters of modern English alphabet: 'a' and 'b'. It's also known, that no ancient word contains two letters 'a' in a row. CJ-17 has already recognized some of the word letters, the others are still unknown.

CJ-17 wants to look up all valid words that could be written on this paper in an ancient dictionary. He needs your help. Find him the word, which is the first in alphabetical order and could be written on the paper.

Input format

The first line contains non-empty string s consisting of 'a', 'b' and '?' characters. Character '?' corresponds to unrecognized letter.

It's guaranteed, that there exists at least one ancient word, that could be written on the paper.

Constraints

Length of s is at most 50.

Output format

Output the first in alphabetical order word, that could be written on the paper, found by CJ-17.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
6 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsGreedy Algorithms
Points:10
3 votes
Tags:
Greedy AlgorithmsBasics of Greedy AlgorithmsSortingAlgorithmsMerge Sort
Points:10
8 votes
Tags:
Greedy AlgorithmsAlgorithmsBasics of Greedy AlgorithmsGreedy algorithm