Submission #588511

#TimeUsernameProblemLanguageResultExecution timeMemory
588511VandflaskeLove Polygon (BOI18_polygon)Cpython 3
0 / 100
2096 ms17436 KiB
import sys n = int(sys.stdin.readline()) personer = [] elsket1 = [] elsket2 = [] A = [] pile = 0 for _ in range(n): s, t = map(str, sys.stdin.readline().split()) personer.append(s) elsket1.append(t) for l in range(n): elsket2.append(personer.index(elsket1[l])) for _ in range(n): A.append(0) for i in range(n): if A[i] == 0 and A[elsket2[i]] == 0 and i == elsket2[elsket2[i]] and i != elsket2[i] and n % 2 == 0: A[elsket2[i]] = 1 A[i] = 1 for j in range(n): if A[j] == 0 and A[elsket2[j]] == 0 and j != elsket2[j] and n % 2 == 0: A[j] = 1 A[elsket2[j]] = 1 pile += 1 if n % 2 == 1: print(-1) else: print(pile + A.count(0))
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...