1357 - I2P(I)2017_Chen_Hw5 Scoreboard

Time

2017/12/10 18:00:00 2017/12/25 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11729 Sentence reversal
11730 Typo
11731 Reverse and Compare

11729 - Sentence reversal   

Description

Writer: jjjjj19980806       Description: pclightyear        Difficulty: ★★☆☆☆

jjjjj doesn't like long description.

Given several sentences, please modify the sentences so that the order of the words is reversed.

Input

There are multiple lines in each test case.

Each line contains a sentence with several words, or there may be no word within it.

Each word will be separated by one or several whitespace.

Also, whitespaces may appear in the front or in the back of the sentence.

It is guaranteed that:

  • At most 10 lines in each test case.
  • Each line contains at most 100 characters.
  • Contains only lowercase letter in each word.

Output

For each sentence, please output the modified sentence with the reverse sequence of words.

Attention: 

(1) After modification, each word is separated by only one whitespace.

(2) If there is no word in the sentence, you still need to output '\n'.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11730 - Typo   

Description

Writer: jjjjj19980806       Description: pclightyear        Difficulty: ★★★☆☆

Niflheimr aspires to compete with the top coder around the world in the competitive programming contest. One key factor to win the contest is the typing speed. The faster you can type, the less time penalty you will get. But sometimes fast typing may lead to some typos. After Niflheimr's observation, there are four common types of typos:


(1) Niflheimr accidentally types one more character.

(2) Niflheimr accidentally forgets to type one character.

(3) Niflheimr accidentally types one wrong character.

(4) Niflheimr accidentally switches two different adjacent characters.


Now Niflheimr asks you to design a typo detector. Niflheimr will input two strings s (the correct string) and t (the string Niflheimr types). You design must be able to determine whether t meets one of the four types of typo as above.

If you can help Niflheimr, maybe he will teach you how to design an efficient parallel program.

Input

The first line contains an integer T, representing the number of inputs Niflheimr gives to you.

The next T line contains two strings siti, representing the correct string and the string Niflheimr types.

It is guaranteed that:

  • 1 ≤ T ≤ 100
  • 1 ≤ | si |, | ti | ≤ 2×105

Output

For each input, if t meets one of the four types of typo, please output "Yes", otherwise please output "No".

Sample Input  Download

Sample Output  Download

Tags




Discuss




11731 - Reverse and Compare   

Description

Source: AtCoder Grand Contest       Writer: tourist       Difficulty: ★★★★★

Given a string S consisting of lowercase English letters, you can choose any two indices i and j such that ≤ i ≤ j ≤ | S | and reverse substring S[i..j].

If you can perform this operation at most once, how many different strings can you obtain?


For example, if S = 'aatt':

You can obtain 'aatt(don't do anything), 'atat(reverse S[2..3]), 'atta(reverse S[2..4]), 'ttaa(reverse S[1..4]) and 'taat(reverse S[1..3]).

Input

The input contains only one string S.

It is guaranteed that :

  • 1 ≤ | S | ≤ 2×105
  • S consists of lowercase letters.

Output

Please output the number of different strings you can obtain by reversing any substring in S at most once.

Sample Input  Download

Sample Output  Download

Tags




Discuss