Task: | Vaihdot |
Sender: | Metabolix |
Submission time: | 2020-10-16 18:56:56 +0300 |
Language: | Python3 (CPython3) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.05 s | 1, 2 | details |
#2 | ACCEPTED | 0.23 s | 2 | details |
Code
#!/usr/bin/python3 t = int(input()) for _ in range(t): n = int(input()) luvut = [0] + list(map(int, input().split())) paikat = [luvut.index(i) for i in range(n+1)] vaihdot = [] mahdoton = False for i in range(n+1): if luvut[i] != i: j = paikat[i] li = luvut[i] lj = luvut[j] if i+1 < j: vaihdot.append("%d %d" % (i, j)) else: if i - 1 >= 2: k = 1 elif n - i >= 3: k = n else: mahdoton = True break vaihdot.append("%d %d" % (i, k)) vaihdot.append("%d %d" % (k, j)) vaihdot.append("%d %d" % (i, k)) luvut[i], luvut[j] = luvut[j], luvut[i] paikat[li], paikat[lj] = paikat[lj], paikat[li] if mahdoton: print("-1") else: print(len(vaihdot)) for v in vaihdot: print(v)
Test details
Test 1
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
1000 1 1 2 1 2 ... |
correct output |
---|
0 0 -1 0 -1 ... |
user output |
---|
0 0 -1 0 -1 ... Truncated |
Test 2
Group: 2
Verdict: ACCEPTED
input |
---|
1000 79 49 42 77 41 37 61 46 55 7 72 4... |
correct output |
---|
81 67 79 70 78 3 77 60 76 ... |
user output |
---|
83 1 58 2 45 3 16 4 29 ... Truncated |