Prázdny
Prázdny

Task 3

Login required

25. 10. 2023 18:00 | You can get 3 points for the task

Stringeria

Once upon a time, in a mystical land known as Stringeria, there lived two remarkable siblings, Stringelia and Stringarion. These siblings were not ordinary at all, they were able to create a magical connection with letters in words. Both of the siblings were gifted with the art of crafting beautiful strings, each composed of letters that danced like fireflies on a warm summer night. As the siblings grew, their miraculous words began to differ slightly.

 

But one fateful day, a dark shadow fell upon Stringeria. A powerful curse, cast by an envious sorcerer, crept through the land, and the once thriving kingdom was plunged into turmoil. The curse shattered the kingdom into fragments, messed up its stories, its songs, and its history.

 

Break of the curse for the region was possible only thanks to the finding of the longest common sequence of magic strings created by Stringelia and Stringarion. Help us to save Stringeria and find sequence, which will break the curse.

 

Find the longest common subsequence in the strings s1 and s2, where characters don't need to follow each other directly.

  • Let the output be the given string
  • and the length of this sequence.
  • At the end attach the source code of your program.

TXT INPUT HERE

 

 

 

Example input:

s1 = "ABECF"

s2 = "AEEDC"

 

Example output:

"AEC"

3

 6

 

SOLUTION HERE