-
-
Save huffman/3753839 to your computer and use it in GitHub Desktop.
GCJ 2008 Qualification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from sys import stdin | |
from sets import Set | |
for case in xrange(int(stdin.readline())): | |
num_engines = int(stdin.readline()) | |
engines = [] | |
for _ in xrange(num_engines): | |
engines.append(stdin.readline()) | |
seq_set = Set([]) | |
min_switches = 0 | |
for _ in xrange(int(stdin.readline())): | |
query = stdin.readline() | |
seq_set.add(query) | |
if len(seq_set) == num_engines: | |
seq_set = Set([query]) | |
min_switches += 1 | |
print 'Case #%i: %i' % (case + 1, min_switches) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sets exist in the main namespace