Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Algorithm, must be written in Java code. The program is tested by a website that has several tests (the website gives inputs, which the program

Algorithm, must be written in Java code. The program is tested by a website that has several tests (the website gives inputs, which the program must react to). It needs to contain a scanner of some sort so the website can make inputs.

In this program, you will recieve a series of attacks, and each attack must be countered with specific blocks. The enemy has 4 different attacks: C, L, R, and S. You can counter each attack with the respective block: M, E, C, and S. The attacks can come from your enemy in any order, and you have to block each of them with the corresponding letter, in the same order as the enemy.

The exact sequence 'C L R S' from the enemy in a row is a super attack, and must be countered by the super block 'F'. An enemy attack can only belong to one combo (with priority to the first one encountered), and all 4 attacks in a combo must be countered by the single super block and nothing else. So for instance 'C R L S C' must be countered by 'F M'.

Given the sequence of all the enemy attacks, you must output the list of blocks you should make.

Input format:

First line: an integer N, indicating the number of attacks your enemy makes . Second line: N space separated letters, indicating your enemy's attacks. The letters will always be one of 'R', 'L', 'C', or 'S'.

Output format:

One line containing the letters of your counter attacks separated by space. All letters should be one of 'M', 'E', 'C', 'S', or 'F'.

image text in transcribed

image text in transcribed

Examples Input 1 8 2 CLRCSRCL Output 1 MECME Input 1 17 2 CRLSR LCS LLCR SLRCS Output 1 FFEFF

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions