Sicily 13460. Passwords

來源:互聯網
上載者:User

標籤:sicily

13460. PasswordsConstraints

Time Limit: 1 secs, Memory Limit: 256 MB

Description

Mirko is an evil plotting genius and has gotten hold of a list of all possible passwords for a certain user account. The first thing he noticed was all the passwords are of odd length. Mirko assumes that the correct password is the one which can be found in both the original and reverse order in the list. For example, if the word “tulipan” would be the correct password, the word “napilut” has to also appear in the list. Given that both words are correct passwords, Mirko will try to use both, one at a time.

Help Mirko discover what the correct password is and output its length and central character.

Input

The first line of input contains the integer N (1 ≤ N ≤ 100), the number of possible passwords. Each of the following N lines contains a single word, its length being an odd number greater than 2 and lesser than 14. All characters are lowercase letters of the English alphabet.

Output

The first and only line of output must contain the length of the correct password and its central letter. The solution will be unique.

Sample Input
範例1:4lasgodpsalasal範例2:4kisikptqtttrptulipan
Sample Output
範例1:3 a範例2:5 s
Hint

Clarification of the first example: The required pair of words is “las” and “sal”. Their length is 3 letters and the central character is ‘a‘.

Clarification of the second example: The word “kisik” can be found in both the original and reverse order on the list (the word is a palindrome), so it is a valid correct password.

Problem Source

2015年每周一賽第一場

#include <iostream>#include <algorithm>#include <vector>#include <string>using namespace std;int main() {std::ios::sync_with_stdio(false);int n;cin >> n;vector<string> v(n);for (int i = 0; i < n; i++) cin >> v[i];for (int i = 0; i < v.size(); i++) {string s = v[i];reverse(s.begin(), s.end());for (int j = 0; j < v.size(); j++) {if (s == v[j]) {cout << v[j].size() << " " << v[j][v[j].size() / 2] << endl;return 0;}}}return 0;}

Sicily 13460. Passwords

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.