PROSCORE - Problem Set Score
Fegla, one of the ACM ICPC coaches, is very happy as one of his teams won the ACPC regional contest, and now he is preparing his team for the ACM ICPC World Final. He decided to establish a training camp for his team in the north coast, practicing on subset of problem sets from previous World Final contests to sharpen the team skills, but he needs to choose this subset wisely as World Final is soon.
After a long discussion with his team, they agreed on a certain criteria to choose the problem sets that will help in the training. Considering a problem set with N teams and P problems, a good problem set must satisfy the following conditions to be chosen:
- Any problem is solved by at least one team.
- Minimum number of solved problems per team is one.
- Maximum number of solved problems per team is less than p.
Although they are all programmers, these lazy guys would to ask for your help in writing a program to calculate that for them. We really doubt that they will do something in the World Finals with such behavior, so kindly help them, even if you are not from their school to state these 3 conditions for a given problem set. But, push them for some work, represent the true condition as 1 and the false condition as 0, and then convert the result to a decimal number to be the problem set score. Let the first condition to be the most left bit, the third condition to be the right most bit and the second condition to be middle bit. E.g. if a problem set matched only the first condition, it's represented as "100" and converted to 4.
Input Specification:
First line contains an integer T that represents the number of test cases, then follow T test cases, each in the following format: Line 1 contains two integers N and P, space separated, where 0 < N, P ≤ 10. Then N lines each contains P integers are followed, where i-th line and j-th column represent (team=i, problem=j) state: 1 if problem is solved and 0 otherwise.
Output Specification:
For each test case, print on one line, “Case K: score” where K is the Test Case number and score is the problem set score.
Sample input:
1
2 3
1 1 1
0 0 0
Sample Output:
Case 1: 4
hide comments
mkfeuhrer:
2016-06-03 13:59:40
take care of way of output ....1WA :-/ |
|
avisheksanvas:
2016-05-14 16:06:46
Don't forget to initialise values in the beginning. Cost me 3 WA's :p
|
|
rahul_verma:
2016-02-23 08:53:46
showing "Internal Server Error" plz help !!!!!! |
|
r0bo_dart:
2015-06-26 09:36:35
Easy ... Hint... use a n + 1 x p + 1 matrix :D |
|
:.Mohib.::
2015-05-30 07:27:49
Easy... ;) |
Added by: | Mostafa Saad Ibrahim |
Date: | 2011-11-13 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | 10th Egyptian Collegiate Programming Contest |