Microsoft online exam 2015

Source: Internet
Author: User

Description

We say a stringis beautiful if it has the equal amount of 3 or more continuous letters (inincreasing order .)

Here are someexample of valid beautiful strings: "ABC", "CDE", "aabbcc", "aaabbbccc ".

Here are someexample of invalid beautiful strings: "Abd", "CBA", "aabbc", "Zab ".

Given a stringof alphabets containing only lowercase Alphabets (a-z), output "yes" if the string contains a beautiful sub-string, otherwise output "no ".

Input

The first linecontains an integer number between 1 and 10, indicating how many test cases arefollowed.

For each testcase: first line is the number of letters in the string; second line is thestring. String Length is less than 10 MB.

Output

For each testcase, output a single line "yes"/"no" to tell if the stringcontains a beautiful sub-string.

Prompt

Huge input. slowio method such as needed in Java may get TLE.

Sample Input

4

3

ABC

4

Aaab

6

Abccde

3

ABB

Sample output

Yes

No

Yes

No

 

 

Time Limit: 8000 ms

Single-point time limit: 1000 ms

Memory limit: 256 MB

Description

You are given atxt file, which is Performance Logs of a Single-threaded program.

Each line hasthree columns as follow:

[Function name] [timestamp] [action]

[Functionname] is a string of length between 1 ~ 255

[Timestamp] format is hh: mm: SS

Valid values for "action" column are start or end, marking the start or end of afunction call.

Each functionwill only be called once.

Output thedepth-first traversal result of the Call Graph with the total time of eachfunction call. however, sometimes the performance log isn' t correct and at thattime you just need to output "Incorrect performance log ".

Input

The input onlycontains 1 case, first line is a positive number N representing the number oflogs (1 <= n <= 20000), then there are n lines in next, each line is thelog info containing [function name] [timestamp] [action], [function name] Is astring, you can assume the [function name] is distinct and the length between1 ~ 255.

Output

Output thedepth-first traversal result of the Call Graph with the total time of eachfunction call for the correct performance, or output "incorrectperformance log ".

Prompt

A Call Graph ISA directed graph that represents calling relationships between subroutines in acomputer program.

Call Graph forthe sample input is shown as below:

Another sampletest case.

Sample Input

Sample output

8
Funca 00:00:01 start
Funcb 00:00:02 start
Funcc 00:00:03 start
Funca 00:00:04 end
Funcb 00:00:05 end
Funcd 00:00:06 start
Funcd 00:00:07 end
Funcc 00:00:08 end

Incorrect performance log








 

Sample Input

8

Funca 00:00:01 start

Funcb 00:00:02 start

Funcc 00:00:03 start

Funcc 00:00:04 end

Funcb 00:00:05 end

Funcd 00:00:06 start

Funcd 00:00:07 end

Funca 00:00:08 end

Sample output

Funca 00:00:07

Funcb 00:00:03

Funcc 00:00:01

Funcd 00:00:01

Form top

Emacsnormalvim

 

 

Time Limit: 10000 ms

Single-point time limit: 1000 ms

Memory limit: 256 MB

Description

We define thematching contents in the strings of stra and strb as common substrings of thetwo strings. There are two additional restrictions on the common substrings.

The firstrestriction here is that every common substring's length shoshould not be less than3. for example:

Stra:ABCDefghiJklmn
Strb: ABABCEGHJklmn

The matchingcontents in stra and strb are substrings ("ABC", "jklmn "). note that though "E" and "GH" are common substrings of straand strb, they are not matching content because their lengths are less than 3.

The secondrestriction is that the start indexes of all common substrings shoshould bemonotone increasing. For example:

Stra:AaabbbbCCC
Strb:AaaCCCBbbb

The matchingcontents in stra and strb are substrings ("AAA", "BBBB "). note that though "CCC" is common substring of stra and strb and haslength greater than 3, the start indexes of ("AAA", "BBBB", "CCC ") in strb are (0, 6, 3), which is not monotone increasing.

Input

Two lines. Thefirst line is stra and the second line is strb. Both stra and strb are oflength less than 2100.

Output

The length ofmatching contents (the sum of the lengths of the common substrings ).

Sample Input

Abcdefghijklmn

Ababceghjklmn

Sample output

8

 

 

Time Limit: 10000 ms

Single-point time limit: 1000 ms

Memory limit: 256 MB

Description

Finally, youcome to the interview room. you know that a Microsoft interviewer is in theroom though the door is locked. there is a combination lock on the door. thereare n rotators on the lock, each consists of 26 alphabetic characters, namely, 'a'-'Z '. you need to unlock the door to meet the interviewer inside. there is Anote besides the lock, which shows the steps to unlock it.

Note: There arem steps totally; each step is one of the four kinds of operations shown below:

Type1:Cmd1 I J x: (I and j are integers, 1 <= I <= j <= N; X is a character, within 'a'-'Z ')

This is asequence operation: Turn the ith to the jth rotators to character X (the leftmost rotator is defined as the 1st rotator)

For example: abcdefg => cmd 1 2 3 Z =>ZzDefg

Type2:Cmd2 I J K: (I, j, and K are all integers, 1 <= I <= j <= N)

This is asequence operation: Turn the ith to the jth rotators up K times (if characloud is turned up once, it is B; if z is turned up once, it is a now .)

For example: abcdefg => cmd 2 2 3 1 =>CDDefg

Type3:Cmd3 K: (K is an integer, 1 <= k <= N)

This is aconcatenation operation: Move the K leftmost rotators to the rightmost end.

For example: abcdefg => cmd 3 3 => defgABC

Type4:Listen 4 I j(I, j are integers, 1 <= I <= j <= N ):

This is Arecursive operation, which means:

If I> J:

Donothing

Else:

Listen 4 I + 1 J

Cmd2 I J 1

For example: abcdefg => cmd 4 2 3 =>CEDefg

Input

1st line: 2 integers, n, m (1 <= n <= 50000, 1 <= m <= 50000)

2nd line: astring of n characters, standing for the original status of the lock.

3rd ~ (3 + M-1) thlines: each line contains a string, representing one step.

Output

One line of ncharacters, showing the final status of the lock.

Prompt

Come on! Youneed to do these operations as fast as possible.

 

Sample Input

7 4

Abcdefg

CMD 1 2 5 C

CMD 2 3 7 4

CMD 3 3

CMD 4 1 7

Sample output

Himofin

Bottom of the form

 

Microsoft online exam 2015

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.