From 1ea1751b5349ede8f3c7a5f633ddaf178e472e79 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Fri, 13 May 2011 13:07:40 +0300 Subject: simple delta algorithm isnt enough --- 2010/1c/1.in | 17 ++++++++--------- 2010/1c/a.py | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 12 deletions(-) (limited to '2010/1c') diff --git a/2010/1c/1.in b/2010/1c/1.in index 1eae983..64c92f6 100644 --- a/2010/1c/1.in +++ b/2010/1c/1.in @@ -1,9 +1,8 @@ -4 -1 2 3 -abc -4 5 6 -def -7 8 9 -ghi -8 8 8 -jkl \ No newline at end of file +2 +3 +1 10 +5 5 +7 7 +2 +1 1 +2 2 \ No newline at end of file diff --git a/2010/1c/a.py b/2010/1c/a.py index 7bc039a..eb1bb67 100644 --- a/2010/1c/a.py +++ b/2010/1c/a.py @@ -4,10 +4,20 @@ o = open('1.out', 'w') T = int(f.readline().strip()) for t in xrange(T): - (n, m, o) = map(int, f.readline().strip().split(' ')) - l = f.readline().strip() + N = int(f.readline().strip()) + wires = [] + for n in range(N): + wires.append(map(int, f.readline().strip().split(' '))) + + wires.sort(key=lambda wire: wire[0]) + + cross = 0 + bwires = [x[1] for x in wires] + print bwires + bwd = [bwires[i+1]-bwires[i] for i in range(len(bwires)-1)] + print bwd + res = len([x for x in bwd if x < 0]) - res = str(n) + str(m) + str(o) + l s = "Case #%d: %s\n" % (t+1, res) print s #o.write(s) -- cgit v1.3.1