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

prefix Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

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

prefix.html

CERN the Lean Tree is a Dryad who likes Physics a lot (Why do you think he is called CERN? Because he likes particle physics!). He wants to join the Incredibly Pro holy Oracles (IPhO) team, as he is told that the IPhO members are all extremely pro in physics and can use their extremely incredible physics skills to predict the future (and find the Higgs Boson). However, he can only enter the IPhO team if he can pass the selection test set by Barr the Bear.

Barr the Bear has given CERN the Lean Tree N strings, filled with only numbers and alphabets, and has told him that he needs to decode the name of the Chosen One from the strings. After asking Kang the Penguin for help (ok, this is cheating, but who cares?), CERN the Lean Tree has found out that the name of the Chosen One is the longest prefix that is common to all the strings.

Sadly, CERN the Lean Tree does not know THAT much programming (he has been spending his whole life on Physics you see), so he needs your help again (ok, this is cheating again, but who cares?). Can you help him solve the riddle and make his dream come true?

Input

The first line contains N, denoting the number of strings given in the input.

The next N lines contains an alphanumeric string each.

Output

Output on a single line a string that is the name of the Chosen One, i.e. the longest common prefix of all the strings.

Constraints

For 30% of test data, N ≤ 10.

For 70% of test data, N ≤ 100.

For 100% of test data, N ≤ 1,000.

For 100% of test data, the length of each string is at most 1,000 characters.

Sample Input 1

3
zrOzrOLinSenOrzOrz
zrOzrOLinSenOwnsOrzOrz
zrOzrOLinSenSoProOrzOrz

Sample Output 1

zrOzrOLinSen

Explanation for Sample Output 1

Clearly, the string "zrOzrOLinSen" is the longest prefix that is common to all the given strings:
  • zrOzrOLinSenOrzOrz
  • zrOzrOLinSenOwnsOrzOrz
  • zrOzrOLinSenSoProOrzOrz

Tags

Raffles Team Selection Contest 2011

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100101s32MBAverage
2011s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o prefix -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.