oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

scary Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

scary.html

Problem Description

Coco the Monkey is still very obsessed with strings.

Sometimes, Coco finds some strings scary, as they frighten Coco the Monkey. Scary strings contain substrings that Coco the Monkey hate.

Coco the Monkey considers a string to be scary, if it contains strings A, B and C as substrings.

Coco the Monkey is now busy hiding on a coconut tree after having a nightmare due to scary strings. Damian wants to frighten Coco the Monkey even more, so he wants to construct a scary string to show Coco the Monkey. Constructing a string is a tiring task, so Damian wants to construct a string that is as short as possible.

Help Damian find the length of the shortest scary string that he can construct.

Input

The first line of input will contain string A, the second line will contain string B and the third line will contain string C. All three strings contain only lowercase english alphabets and do not contain any other characters.

Output

Output a single string, the length of the shortest scary string that Damian can construct.

Limits

Subtask 1 (38%): 1 ≤ | A |, | B |, | C | ≤ 500.

Subtask 2 (62%): 1 ≤ | A |, | B |, | C | ≤ 100 000.

Subtask 3 (0%): Sample Testcases

Sample Testcase 1

Input

rar
the
cat

Output

8

Tags

String Processing

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
138131s64MBMinimum
262181s64MBMinimum
3011s64MBMinimum

Judge Compile Command

g++-8 ans.cpp -o scary -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.