Task: | Graph painting |
Sender: | Verto |
Submission time: | 2016-05-28 13:09:34 +0300 |
Language: | Python2 |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.05 s | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
Code
import sysdef asints(s):return [int(x.strip()) for x in s.split()]def asoneint(s):return int(s.strip())lines = sys.stdin.readlines()class Node:def __init__(self, name):self.name = nameself.neighbors = []self.color = Nonedef connect(self, other):self.neighbors.append(other)other.neighbors.append(self)def debug(self):print "{}: {}".format(self.name, [x.name for x in self.neighbors])t = asoneint(lines[0])linei = 1for testi in range(t):nodes = {}n, m = asints(lines[linei])linei += 1for i in range(1, n+1):nodes[i] = Node(i)for i in range(m):a, b = asints(lines[linei])linei += 1nodes[a].connect(nodes[b])#for node in nodes.values():# node.debug()for node in nodes.values():n_red = 0n_blue = 0for neigh in node.neighbors:if neigh.color is None:continueelif neigh.color == 'R':n_red += 1else:n_blue += 1if n_red > n_blue:node.color = 'B'else:node.color = 'R'for node in sorted(nodes.values(), key=lambda x:x.name):print node.color,
Test details
Test 1
Verdict: ACCEPTED
input |
---|
100 7 1 2 5 8 28 2 7 ... |
correct output |
---|
B R B B B B R R B B R B R B B R R B B B B R R R B B B R B R B B B B R B R R B R ... |
user output |
---|
R R R R B R R R B R B R B R B R B R B R R R R B R R B R B R B R B B R R R B B R ... |
Test 2
Verdict: ACCEPTED
input |
---|
10 38 36 18 28 20 37 22 38 ... |
correct output |
---|
R R B R B R R R R R B B R B R ... |
user output |
---|
R R R R R R R R R R B R R R R ... |
Test 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1 100000 200000 89300 98492 33853 56822 92967 99427 ... |
correct output |
---|
R R R R B R R R B B B R B B B ... |
user output |
---|
(empty) |