DCP-232: Game of MODs Back to All Problems

Medium Recursion > Backtracking with Pruning/Branch and Bound


**BigMOD** is a ***very intelligent boy***. He likes mathematics and mathematical games. He often challenge his friends in various mathematical games. But all his friends are not good at mathematics and when **BigMOD** challenges his friends and they can’t answer the problem properly he feel very proud. But today his friend **LittleMOD** who is a great programmer challenge him to solve a problem like this: **LittleMOD** give him two integer number N and K and ask him ***"what is the maximum and minimum number can be get from N after deleting exactly K digits from N without changing the order of the digits?"*** Though **BigMOD** is good at mathematics but he is not good in programming and he wants to win this challenge so he wants your help to solve this problem. Can you help **BigMOD** to defeat **LittleMOD** in this game ? Input: ------ Input starts with an integer **(1<=T≤200)** which denotes the number of test case. Each test case consists of two integers N and Q **(0<=N<10^10 and 1<=Q<=100)** Where N is the given Number by **LittleMOD** and **Q** is the number of query. The next line contains Q space separated integers which denotes the value of **K ( 0<=K<=|N| )** Here **|N|** denotes the ***number of digits in N***. Output: ------- For each test case, print the case number at first. Then for each **K** given in query print the maximum and the minimum number without leading zeros which are the answer for **BigMOD** in the above game. In case of K=|N|, you should output a line with two zeros separated by a space. See the sample input and output for better understanding. Sample Input ------------ 2 1234 2 1 2 1578 1 3 Sample Output ------------- Case 1: 234 123 34 12 Case 2: 8 1


Problem Setter:

Tanmoy Tapos Datta

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 3.00
C++ 3.00
C++14 3.00
C# 5.00
Go 5.00
Java 4.00
JavaScript 5.00
Objective-C 5.00
Perl 5.00
PHP 5.00
Python 5.00
Python3 5.00
Ruby 5.00
VB.Net 5.00

Problem Stats

54/387

Solve/Submission

Ranking

# User Language Timing
01 feodorv C 0.01s
02 SugiuraAyano C 0.01s
03 Morass Cpp14 0.02s
04 BishalG Cpp14 0.02s
05 maxhasan Cpp14 0.02s
06 ovis96 Cpp14 0.03s
07 njrafi Cpp14 0.03s
08 rayhan50001 Cpp 0.03s
09 wayne6172 C 0.03s
10 tariqiitju Cpp14 0.03s
11 KIRIN_36 Cpp 0.04s
12 obujgalib Cpp 0.04s
13 Arpan_cse_2k14 Cpp14 0.04s
14 emrul Cpp 0.08s
15 ssavi Cpp14 0.08s
16 _GhOstMan_ Cpp14 0.11s
17 Digonta Cpp14 0.11s
18 Robbinb1993 Cpp14 0.11s
19 showmic Cpp14 0.17s
20 Maruf_75 Cpp 0.20s
21 sazal_dev Cpp 0.34s
22 Reayz Cpp 0.34s
23 kissu_pari_na Cpp14 0.34s
24 rajdipsaha Cpp 0.36s
25 _dipu Cpp14 0.38s
26 FariD Cpp14 0.48s
27 bishal_biswas Cpp14 1.11s
28 Mr_adnan Cpp14 1.23s
29 twyu0721 C 2.58s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support