You are given a paired string s of length n (a line of n characters 0 and additionally 1) and an integer k. How about we indicate the string s[i..j] as the substring of s beginning from the I-th character and finishing with the j-th character (that is, s[i..j]=sisi+1si+2… sj−1sj).    We should call a

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

 

 

You are given a paired string s of length n (a line of n characters 0 and additionally 1) and an integer k. How about we indicate the string s[i..j] as the substring of s beginning from the I-th character and finishing with the j-th character (that is, s[i..j]=sisi+1si+2… sj−1sj). 

 

We should call a paired string t of length k wonderful in case it is somewhat like all substrings of s having length precisely k; that is, it is somewhat like s[1..k],s[2..k+1],… ,s[n−k+1..n]. 

 

You will likely find the lexicographically littlest string t that is lovely, or report that no such string exists. String x is lexicographically not as much as string y if either x is a prefix of y (and x≠y), or there exists such I (1≤i≤min(|x|,|y|)), that xi<yi, and for any j (1≤j<i) xj=yj. 

 

Input 

 

The main line contains one integer q (1≤q≤10000) — the number of experiments. Each experiment comprises of two lines. 

 

The principal line of each experiment contains two integers n and k (1≤k≤n≤106). The subsequent line contains the string s, comprising of n characters (each character is either 0 or 1). 

 

It is ensured that the amount of n over all experiments doesn't surpass 106. 

 

Output 

 

For each experiment, print the appropriate response as follows: 

 

in case it is difficult to build a wonderful string, print one line containing the string NO (note: precisely in capitalized, you can't print No, for instance); 

 

in any case, print two lines. The principal line ought to contain the string YES (precisely in capitalized also); the subsequent line — the lexicographically littlest excellent string, comprising of k characters 0 or potentially 1.

 

 

 

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education