UF2015B - Research Problems
Academic research is not all it's cracked up to be. There are scandals everywhere, ranging from plagiarism to fudging numerical data. Some academic papers get more scrutiny than others, such as when some unfortunate soul claims he/she has proven that P=NP; in these cases the authors and their 'results' are quickly put to shame.
In the interest of maintaining the integrity of academia, researchers everywhere would really benefit from having a computer program that could determine if a certain research paper is accurate or not. Unfortunately it's not possible to verify a paper accurately. Instead, it is much easier (but still helpful) to identify circular reasoning. Circular reasoning is characterized by the ability to continually follow the references of research papers and end up back at the paper you started with. Given a set of papers, can you determine if there are any cases of circular reasoning?
Input
The input will begin with a line containing a single positive integer, t, representing the number of test cases to process. Each test case will begin with a single integer N (1 ≤ N ≤ 100) which is the number of papers in this test case. The i-th paper starts with "i: " and is followed by text. The text for a paper may span multiple lines, there will be no ":" character used other than at the beginning of a paper, and a "*" character will signify the end of a test case. Inside the text will be a set of references; you may assume that any number in a paper's contents is a reference to a valid paper in the current set.
Output
For each test case output "No problems here, sir" if there is no circular reasoning; otherwise output "We have got some problems". The output for each test case should be on its own line.
Example
Input: 2 4 1: Abstract. In this paper we describe a universal algorithm that proves P is a proper subset of NP. We utilize results from [2], [3], and [4]. 2: Hello this is a totally truthful result. 3: Another totally truthful result using [4]. 4: Wow this can't be entirely truthful. [2] * 2 1: Shocking result where Euler's theorem turned out to not actually be true! [2] 2: Pigs can fly. [1] * Output: No problems here, sir We have got some problems
Added by: | Cormac |
Date: | 2015-02-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |
Resource: | UF High School Programming Contest 2015 |