-
Notifications
You must be signed in to change notification settings - Fork 5
/
Prerequisites.java
44 lines (37 loc) · 1.02 KB
/
Prerequisites.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package uva;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Prerequisites {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int k,category,c,r;
String temp,cCourse;
boolean getDegree;
while ((k=in.nextInt())!=0) {
category = in.nextInt();
Map<String,Integer> fCourses= new HashMap();
getDegree=true;
for ( int i = 0; i < k; i++) {
temp=in.next();
fCourses.put(temp, 1);
}
for ( int i = 0; i < category; i++ ) {
c= in.nextInt();
r= in.nextInt();
for ( int j = 0; j < c; j++ ) {
cCourse = in.next();
if(fCourses.get(cCourse)!=null)
r--;
}
if ( r > 0 )
getDegree = false;
}
if ( getDegree )
System.out.println("yes");
else
System.out.println("no");
}
}
}