Created
May 13, 2011 01:13
-
-
Save okaq/969780 to your computer and use it in GitHub Desktop.
Solution: GoroSort (Google Code Jam 2011 Qualification Round Problem D)
This file contains 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
import sys | |
fin = file(sys.argv[1]) | |
fout = open(sys.argv[2], 'w') | |
lines = fin.readlines() | |
goros0 = [map(int, line.split()) for line in lines] | |
goros = [] | |
tests = goros0.pop(0) | |
for i in range(1, len(goros0), 2): | |
goros.append(goros0[i]) | |
data = [] | |
for i in range(len(goros)): | |
sg = list(goros[i]) | |
sg.sort() | |
c0 = 0 | |
for j in range(len(goros[i])): | |
if (sg[j] != goros[i][j]): | |
c0 += 1 | |
data.append(c0) | |
for i in range(len(data)): | |
fout.write("Case #%d: %d\n" % ((i + 1), data[i])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment