Skip to content

Instantly share code, notes, and snippets.

@avamsi
Created February 2, 2016 17:23
Show Gist options
  • Save avamsi/bfd61495486e3c987a6c to your computer and use it in GitHub Desktop.
Save avamsi/bfd61495486e3c987a6c to your computer and use it in GitHub Desktop.
for t in xrange(1, int(raw_input()) + 1):
n, q = map(int, raw_input().split())
qs = [map(int, raw_input().split()) for _ in xrange(q)]
print 'Scenario #%s:' % t
ref = [0] * (n + 1)
for a, b in qs:
if ref[a] >= ref[b] > 0:
if ref[a] != ref[b]:
print 'Suspicious bugs found!'
break
elif ref[a] == ref[b] == 0:
ref[a] = ref[b] = -1
else:
if ref[a] > 0:
ref[b] = ref[a]
elif ref[b] > 0:
ref[a] = ref[b]
else:
ref[a] = ref[b] = -1
else:
print 'No suspicious bugs found!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment