nilmish.iit
BAN USER- 0of 2 votes
AnswersMastermind is a game of two players. In the beginning, first player decides a secret key, which is a sequence (s1,s2,...sk) where 0 < si <= n, Then second player makes guesses in rounds, where each guess is of form (g1,g2, ...gk), and after each guess first player calculates the score for the guess. Score for a guess is equal to number of i's for which we have gi = si.
- nilmish.iit in United States
For example if the secret key is (4,2,5,3,1) and the guess is (1,2,3,7,1),then the score is 2, because
g2 = s2 and g5 = s5.
Given a sequence of guesses, and scores for each guess, your program must decide if there exists at least one secret key that generates those exact scores.
Input
First line of input contains a single integer C (1 <=C <= 100). C test-cases follow. First line of each test-case contains three integers n,k and q. (1 <=n,k <=11, 1<=q<=8). Next q lines contain the guesses.
Each guess consists of k integers gi,1, gi,2,....gi,k separated by a single space, followed by the score for the guess bi (1 <= gi,j<=n for all 1 <=i <=q, 1 <=j <=k; and 0 <= bi <=k )
Output
For each test-case, output "Yes" (without quotes), if there exists at least a secret key which generates those exact scores, otherwise output "No".
Sample Input
2
4 4 2
2 1 2 2 0
2 2 1 1 1
4 4 2
1 2 3 4 4
4 3 2 1 1
Sample Output
Yes
No| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm
Repathenajbarnarda, Android Engineer at ABC TECH SUPPORT
I am a graduate in Civil Engineering with nearly 7 years of experience in planning and implementing technical solutions for ...
RepAtharvFlores, Accountant at A9
I am working as a position of a court clerk to assist the judges as attorneys in expediting the court ...
RepEllaScotz, abc at A9
I am a creative designer with innovative ideas and a unique approach to visuals. I am also a skilled painter ...
RepJenniaLopez, Associate at Absolute Softech Ltd
Jennia , a hard-working Packer with a strong determination to finish all assignments in a timely manner. Replaces , operates and maintains ...
RepCamilaHill, Accountant at ADP
I am a performance-driven leader providing high-level administrative and operational support, coordinating schedules, preparing travel and documents, and exploring Surah ...
RepAasiHarris, abc at 8x8
I am a creative designer with innovative ideas and a unique approach to visuals. I am also a skilled painter ...
Repericsumm059, Backend Developer at ASU
My name is EricSummey . I am working as a Sound engineering technician at Foreman & Clark . as a sound technician it ...
RepEileenWenda, DIGITAL MARKETING at Accenture
I am Eileen , a football Referee skilled at maintaining a safe environment for both players and observers, inspecting the playing ...
Repwoodscarla116, Associate at ASAPInfosystemsPvtLtd
I am a nurse . My name is CarlaWoods . I am working as a Clinical social worker. I met many people ...
RepZoeKim, AT&T Customer service email at A9
Holds a job in the social work sector and directly deals primarily with women and children who are fleeing domestic ...
the time limit is 3 sec...i have figured out a brute force solution of doing it by generating all the possible permutations...but that wd definitely time out...how can we optimise it further...any suggestions...
- nilmish.iit October 26, 2012