Skip to content

Instantly share code, notes, and snippets.

@pikeas
Created October 9, 2011 17:03
Show Gist options
  • Save pikeas/1273917 to your computer and use it in GitHub Desktop.
Save pikeas/1273917 to your computer and use it in GitHub Desktop.
#Replace readline() with raw_input for actual submission
f = open('test')
N = int(f.readline())
points = [f.readline() for i in xrange(N)]
Q = int(f.readline())
moves = [f.readline() for i in xrange(Q)]
for i in xrange(N):
[x, y] = [int(j) for j in points[i].split()]
#Process points
#print 'added %d' % i
#Build a tree or something here
for m in moves:
op, i, j = m.split(' ')
i, j = int(i), int(j)
#Process moves
#######And here's a script you can use to generate test input.
#! /usr/bin/python
import sys, random, cStringIO
t = cStringIO.StringIO()
_, N, Q = sys.argv
N, Q = int(N), int(Q)
p1 = [random.randint(-sys.maxint, sys.maxint) for i in xrange(N)]
p2 = [random.randint(-sys.maxint, sys.maxint) for i in p1]
q1 = [random.randint(1, N) for i in xrange(Q)]
q2 = [random.randint(i, N) for i in q1]
p = zip(p1, p2)
q = zip(q1, q2)
print >>t, N
for i in p: print >>t, '%d %d' % (i[0], i[1])
print >>t, Q
for i in q: print >>t, '%s %d %d' % (random.choice(['X', 'Y', 'C']), i[0], i[1])
f = open('test', 'w')
f.write(t.getvalue())
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment