Submission #588511

# Submission time Handle Problem Language Result Execution time Memory
588511 2022-07-03T12:33:55 Z Vandflaske Love Polygon (BOI18_polygon) Python 3
0 / 100
2000 ms 17436 KB
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 time Memory Grader output
1 Incorrect 17 ms 2900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2836 KB Output is correct
2 Correct 13 ms 2900 KB Output is correct
3 Correct 13 ms 2868 KB Output is correct
4 Execution timed out 2096 ms 17436 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2090 ms 17324 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 2900 KB Output isn't correct
2 Halted 0 ms 0 KB -