eolymp
bolt
Try our new interface for solving problems
Məsələlər

Bracelets

Bracelets

Finally, Megamind has devised the perfect plan to take down his arch-nemesis, Metro Man! Megamind has designed a pair of circular power bracelets to be worn on his left and right wrists. On each bracelet, he has inscribed a sequence of magical glyphs (i.e., symbols); each activated glyph augments Megamind’s strength by the might of one grizzly bear! However, there’s a catch: the bracelets only work when the subsequences of glyphs activated on each bracelet are identical. For example, given a pair of bracelets whose glyphs are represented by the strings "\textbf{metrocity}" and "\textbf{kryptonite}", then the optimal activation of glyphs would give Megamind the power of \textbf{10} grizzly bears: Figure 1: Megamind’s power bracelets On the first bracelet, the letters "\textbf{etoty}" are activated in clockwise order; the same letters are activated in counterclockwise order on the second bracelet. Generally, the ordering of the letters is important, but the orientation of the activated subsequence on each bracelet (i.e., clockwise or counterclockwise) may or may not be the same---and don’t forget that the bracelets are circular! Help Megamind defeat Metro Man by determining the optimal subsequences of glyphs needed to activate his bracelets. \InputFile The input file will contain at most 100 test cases (including at most \textbf{5} "large" test cases). Each test case is given by a single line containing a space-separated pair of strings \textbf{s} and \textbf{t}, corresponding to the sequences of glyphs on Megamind’s left and right power bracelets, respectively. Each string will consist of only lowercase letters ('\textbf{a}'-'\textbf{z}'). The length of each input string will be between \textbf{1} and \textbf{100} characters, inclusive, except for the large test cases where the length of each input string will be between \textbf{1} and \textbf{1500} characters, inclusive. \OutputFile For each input test case, print the maximum power (in units of grizzly bears) that Megamind will be able to achieve by activating glyphs on his bracelets.
Zaman məhdudiyyəti 30 saniyə
Yaddaşı istafadə məhdudiyyəti 256 MiB
Giriş verilənləri #1
metrocity kryptonite
megamind agemdnim
metroman manmetro
megamindandmetroman metromanandmegamind
Çıxış verilənləri #1
10
16
16
32
Mənbə ACM ICPC 2011 Pacific Northwest Region Programming Contest