Peer Review
Time limit1sMemory limit128 MB
Given each author's institution and their K assigned papers to review, count how many papers violate review-count, self-review, collaborator, or duplicate-review rules.
- Level
Medium4 of 10
- Topics
- Hash map, Simulation, Implementation
- Solved
- No attempts yet
Problem
At scientific conferences, researchers submit papers describing their ideas and then review one another's papers, so that only strong work is presented. The organizers assign the reviews under three rules:
- Every paper must be reviewed exactly times — never more, never fewer.
- A researcher must not review a paper written by a collaborator. Researchers collaborate when they belong to the same institution, and every author collaborates with themselves, so no one may review their own paper.
- A researcher must not review the same paper more than once.
Write a program that checks whether a conference followed all three rules, so the organizers learn about any violation before it is too late.
Input
The input contains several test cases. The first line of each test case has two integers () and (): is the number of reviews every paper is supposed to receive, and is the number of papers to review. Every paper has exactly one author and every author presents exactly one paper, so there are as many papers as authors.
Each of the next lines describes one author: the name of the institution the author belongs to, followed by the list of the papers that author was asked to review. Researchers from the same institution are assumed to collaborate; researchers from different institutions do not. Every institution name is shorter than 10 characters and consists only of upper- and lowercase letters with no whitespace. Papers are identified by the index of their author: paper was written by the first author listed, and paper by the last.
A line containing and marks the end of the input and must not be processed.
Output
For each test case, print one line:
NO PROBLEMS FOUNDif every paper obeyed all three rules.1 PROBLEM FOUNDif exactly one paper broke a rule.P PROBLEMS FOUNDif papers broke a rule, where .
A paper that breaks several rules still counts as a single problem. Produce no output for the terminating 0 0 line.