gears_count = int(input())
connections_count = int(input())
connections = []
for i in range(connections_count):
inp = input()
connections = connections + [[int(inp.split()[0]), int(inp.split()[1])]]
def get_connections_of_gear(gear=1, connections_arr=[[0]]):
gear_connections = 0
if connections_arr:
for i in range(connections_count * 2):
if connections_arr[i // 2][i % 2] == gear:
gear_connections += 1
return gear_connections
def is_valid():
if gears_count < 3 or connections_count < 3:
return "good"
elif gears_count % 2 == 0:
gears = 0
for i in range(gears_count):
if get_connections_of_gear(i, connections) > 2:
gears += 1
if gears % 2 == 0:
elif not gears_count % 2 == 0:
if not gears % 2 == 0:
return "bad"
print(is_valid())
Объяснение:
8 из 11
Код готов, но дает 7. Однако при использовании совместно с кодом 2, то дает
a = int(input())
b = int(input())
mas = ["test"]
mas01 = []
e = 0
ce = 2
answer = ""
test01 = "Correct"
test02 = ""
test03 = ""
externaltest03 = "NONE"
for i in range(b):
c, d = map(int, input().split())
for m in range(len(mas)):
if c == mas[m]:
e = e + 1
if e != 0:
else:
mas.append(c)
if d == mas[m]:
mas.append(d)
mas01.append(c)
mas01.append(d)
del mas[0]
#First attemp
t = len(mas01) + 1
try:
for i in range(1,t,2):
if mas01[i] == mas01[i + 1]:
pass
test01 = "Incorrect"
break
except:
del i
del e
#Second attemp
if len(mas) == a:
test02 = "Correct"
test02 = "Incorrect"
del a
del mas
#Third attemp
for i in range(0, t - 4, 2):
j = mas01[i]
k = mas01[i + 1]
m = mas01[ce]
n = mas01[ce + 1]
if j == m and k == n or j == n and k == m:
externaltest03 = "Error"
ce = ce + 2
del mas01
#4st attemp
if externaltest03 == "Error":
test03 = "Incorrect"
test03 = "Correct"
del externaltest03
#5st Generate answer
if test01 == "Correct" and test02 == "Correct" and test03 == "Correct":
answer = "Yes"
answer = "No"
print(answer)
test04 = ""
test04error = "NONE"
# Enable console testing?
# If yes, to write for value "START"
enableconsole = "STAR"
#Disable test01?
#If yes, write value "STOP"
disabletest01 = "STOP"
if disabletest01 != "STOP":
#del i
#del e
#del a
#del mas
#del externaltest03
#5st Test04
for i in range(0, len(mas01), 2):
test04error = "Error"
if test04error == "Error":
test04 = "Incorrect"
test04 = "Correct"
#del mas01
#6st Generate answer
if test01 == "Correct" and test02 == "Correct" and test03 == "Correct" and test04 == "Correct":
if enableconsole == "START":
print(mas)
print(mas01)
print(test01)
print(test02)
print(test03)
print(test04)
print(externaltest03)
gears_count = int(input())
connections_count = int(input())
connections = []
for i in range(connections_count):
inp = input()
connections = connections + [[int(inp.split()[0]), int(inp.split()[1])]]
def get_connections_of_gear(gear=1, connections_arr=[[0]]):
gear_connections = 0
if connections_arr:
for i in range(connections_count * 2):
if connections_arr[i // 2][i % 2] == gear:
gear_connections += 1
return gear_connections
def is_valid():
if gears_count < 3 or connections_count < 3:
return "good"
elif gears_count % 2 == 0:
gears = 0
for i in range(gears_count):
if get_connections_of_gear(i, connections) > 2:
gears += 1
if gears % 2 == 0:
return "good"
elif not gears_count % 2 == 0:
gears = 0
for i in range(gears_count):
if get_connections_of_gear(i, connections) > 2:
gears += 1
if not gears % 2 == 0:
return "good"
return "bad"
print(is_valid())
Объяснение:
8 из 11
Код готов, но дает 7. Однако при использовании совместно с кодом 2, то дает
Объяснение:
a = int(input())
b = int(input())
mas = ["test"]
mas01 = []
e = 0
ce = 2
answer = ""
test01 = "Correct"
test02 = ""
test03 = ""
externaltest03 = "NONE"
for i in range(b):
c, d = map(int, input().split())
for m in range(len(mas)):
if c == mas[m]:
e = e + 1
if e != 0:
e = 0
else:
mas.append(c)
for m in range(len(mas)):
if d == mas[m]:
e = e + 1
if e != 0:
e = 0
else:
mas.append(d)
mas01.append(c)
mas01.append(d)
del mas[0]
#First attemp
t = len(mas01) + 1
try:
for i in range(1,t,2):
if mas01[i] == mas01[i + 1]:
pass
else:
test01 = "Incorrect"
break
except:
pass
del i
del e
#Second attemp
if len(mas) == a:
test02 = "Correct"
else:
test02 = "Incorrect"
del a
del mas
#Third attemp
for i in range(0, t - 4, 2):
j = mas01[i]
k = mas01[i + 1]
m = mas01[ce]
n = mas01[ce + 1]
if j == m and k == n or j == n and k == m:
externaltest03 = "Error"
ce = ce + 2
del mas01
#4st attemp
if externaltest03 == "Error":
test03 = "Incorrect"
else:
test03 = "Correct"
del externaltest03
#5st Generate answer
if test01 == "Correct" and test02 == "Correct" and test03 == "Correct":
answer = "Yes"
else:
answer = "No"
print(answer)
a = int(input())
b = int(input())
mas = ["test"]
mas01 = []
e = 0
ce = 2
answer = ""
test01 = "Correct"
test02 = ""
test03 = ""
test04 = ""
externaltest03 = "NONE"
test04error = "NONE"
# Enable console testing?
# If yes, to write for value "START"
enableconsole = "STAR"
#Disable test01?
#If yes, write value "STOP"
disabletest01 = "STOP"
for i in range(b):
c, d = map(int, input().split())
for m in range(len(mas)):
if c == mas[m]:
e = e + 1
if e != 0:
e = 0
else:
mas.append(c)
for m in range(len(mas)):
if d == mas[m]:
e = e + 1
if e != 0:
e = 0
else:
mas.append(d)
mas01.append(c)
mas01.append(d)
del mas[0]
#First attemp
t = len(mas01) + 1
if disabletest01 != "STOP":
try:
for i in range(1,t,2):
if mas01[i] == mas01[i + 1]:
pass
else:
test01 = "Incorrect"
break
except:
pass
#del i
#del e
#Second attemp
if len(mas) == a:
test02 = "Correct"
else:
test02 = "Incorrect"
#del a
#del mas
#Third attemp
for i in range(0, t - 4, 2):
j = mas01[i]
k = mas01[i + 1]
m = mas01[ce]
n = mas01[ce + 1]
if j == m and k == n or j == n and k == m:
externaltest03 = "Error"
ce = ce + 2
#4st attemp
if externaltest03 == "Error":
test03 = "Incorrect"
else:
test03 = "Correct"
#del externaltest03
#5st Test04
for i in range(0, len(mas01), 2):
if mas01[i] == mas01[i + 1]:
test04error = "Error"
if test04error == "Error":
test04 = "Incorrect"
else:
test04 = "Correct"
#del mas01
#6st Generate answer
if test01 == "Correct" and test02 == "Correct" and test03 == "Correct" and test04 == "Correct":
answer = "Yes"
else:
answer = "No"
print(answer)
if enableconsole == "START":
print(mas)
print(mas01)
print(test01)
print(test02)
print(test03)
print(test04)
print(externaltest03)