Professional Documents
Culture Documents
PRESENTS
EXECUTE 12.2
The coding combat
Bail Walter
PROBLEM STATEMENT: Walter is been locked inside the St. Claire's Mental Institution for 17 years now. Olivia and Peter have come to Bail him out because they need him to save the world. In order to get out of the Mental Institution, Walter needs to prove that he is mentally stable. The head of St. Claires Mental Institution gives Walter a String s and asks him to tell the lexicographically largest subsequence of s. For Strings x and y, we say y is a subsequence of x if y can be obtained from x by erasing some (possibly all or none) of the letters in x. For example, "rnge" is a subsequence of "fringe", while "gef" is not. Help Walter answer this easy question with help of a program. NOTE: For strings x and y, x is said to be lexicographically larger than y if y is a prefix of x or y has a smaller character than x at the first position where they differ. Order of characters is defined as the order of ASCII codes: 'a' < 'b' < ... < 'z'. INPUT: The first line of input contains an integer T, the number of test cases. Then T lines follow, each containing a string s. OUTPUT: For each test case, output on a newline the lexicographically largest subsequence of s. CONSTRAINTS: 1<=T<=160 1<=Length(s)<=50 Each character in s will be a lowercase letter ('a'-'z') SAMPLE INPUT: 4 test a fringe aquickbrownfoxjumpsoverthelazydog SAMPLE OUTPUT: tt a rnge zyog TIME LIMIT: 1 sec EXPLANATION: Case #1: All subsequences listed in lexicographical order are (empty string), e, es, est, et, s, st, t, te, tes, test, tet, ts, tst and tt. So answer is tt. Case #2: There are only two subsequences, and a.
Jones Teleporter
PROBLEM STATEMENT: David Robert Jones has built himself a teleporter device and he can teleport himself from one hotspot and another hotspot and vice versa. The hotspots are linked with each other via wormholes through which he teleports himself. One hotpot may be connected with multiple hotspots via these wormholes. Hotspots which are not connected to any other hotspots may also exist. Given the configuration of hotspots, Jones wants to know whether it is possible to teleport from one hotspot A to another hotspot B. INPUT: The first line of input contains an integer T, the number of test cases. Then T test cases follow. First line of each test case contains two space separated integers N and M, denoting number of hotspots and the number of wormholes. Then M lines follow each containing two space separated integers A and B, denoting that there is a wormhole between hotspots A and B. Assume that hotspots are indexed by numbers from 0 to N-1. Next line contains an integer Q denoting the number of queries. Each of the next Q lines contains two integers X and Y. For each query you have to find out if Jones can teleport between hotspot X and hotspot Y. OUTPUT: For each test case print Q lines - one for each query. Output "DISINTEGRATE" if Jones can teleport between the given hotspots and "FREEZE" otherwise (quotes for clarity). NOTE: Teleportation from source to destination can be via intermediate hotspots. There might be multiple wormholes between same pair of hotspots, also there might be a wormhole that links a hotspot to itself. If X=Y, the answer is DISINTEGRATE. CONSTRAINTS: 1<=T<=10 1<=N<=100 1<=M<=600 0<=A,B,X,Y<=N-1 1<=Q<=600 SAMPLE INPUT: 1 42 01 12 3 02 03 21 SAMPLE OUTPUT: DISINTEGRATE FREEZE DISINTEGRATE TIME LIMIT: 3 sec WARNING: Use Fast I/O Methods