From 336782527254cd06db202581db240b0d6384438f Mon Sep 17 00:00:00 2001 From: "Felix C. Stegerman" Date: Sat, 24 Sep 2016 15:00:19 +0200 Subject: [PATCH] ... --- i.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 i.py diff --git a/i.py b/i.py new file mode 100644 index 0000000..1503006 --- /dev/null +++ b/i.py @@ -0,0 +1,17 @@ +from __future__ import print_function +import sys + +m, s = map(int, sys.stdin.readline().split()) +prefs = [ map(int, line.split()) for line in sys.stdin ] +inits = [ set() for x in xrange(m) ] +answer = set() + +for j in xrange(s): + for i in xrange(m): answer.add(prefs[i][j]) + all_ok = True + for i in xrange(m): + inits[i].add(prefs[i][j]) + if len(inits[i]) != len(answer): all_ok = False + if all_ok: break + +print(len(answer)); print(" ".join(map(str, sorted(answer))))