CSES - HIIT Open 2019 - Results
Submission details
Task:Many Cycles
Sender:Agonaudid
Submission time:2019-05-25 14:30:03
Language:Python3
Status:READY
Result:
Test results
testverdicttime
#10.05 sdetails
#20.05 sdetails

Code

def deletethosefucks(j):
	nodestochecknext = graph[j]
	del graph[j]
	for node in nodestochecknext:
		if node in graph.keys():
			graph[node].remove(j)
			deletethosefucks(node)

cases = int(input())

for i in range(cases):
	nodes, edges = list(map(int, input().split()))	 
	graph = {}
	for j in range(nodes):
		graph[j + 1] = []	
	for _ in range(edges):
		a, b = list(map(int, input().split()))
		graph[a].append(b)
		graph[b].append(a)
	somelinse = []	
	for j in graph.keys():
		if len(graph[j]) == 1:
			somelinse.append(j)
	for j in somelinse:
		deletethosefucks(j)
	for j in graph.keys():
		if len(graph[j]) > 2:
			print("YES")
			break
	else:
		print("NO")
	

#	for arr in graph.values():
#		print(arr)
#		if (len(arr) > 2):
#			a += 1
#	if a > 1:
#		print("YES")
#	else:
#		print("NO")

Test details

Test 1

Verdict:

input
1000
100 78
97 68
75 90
58 80
...

correct output
YES
YES
YES
YES
NO
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 25, in <module>
    deletethosefucks(j)
  File "input/code.py", line 2, in deletethosefucks
    nodestochecknext = graph[j]
KeyError: 10

Test 2

Verdict:

input
11
2 1
1 2
6 6
1 2
...

correct output
NO
NO
NO
YES
YES
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 25, in <module>
    deletethosefucks(j)
  File "input/code.py", line 2, in deletethosefucks
    nodestochecknext = graph[j]
KeyError: 2