QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#658215 | #7011. Rikka with Sorting Networks | nekoyellow | TL | 16ms | 10524kb | Python3 | 660b | 2024-10-19 16:23:51 | 2024-10-19 16:23:59 |
Judging History
answer
from itertools import permutations
def solve():
n, k, m = map(int, input().split())
p = []
for i in range(k):
p.append(list(map(int, input().split())))
p[i][0] -= 1
p[i][1] -= 1
cnt = 0
for a in permutations(range(1, n+1)):
a = list(a)
for x, y in p:
a[x], a[y] = min(a[x], a[y]), max(a[x], a[y])
ok = False
for i in range(n):
ordered = True
prev = 0
for j in range(n):
if j == i: continue
if a[j] < prev:
ordered = False
break
prev = a[j]
if ordered:
ok = True
break
if ok:
# print(a)
cnt += 1
print(cnt)
for _ in range(int(input())):
solve()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 16ms
memory: 10524kb
input:
4 4 0 998244353 4 1 998244353 1 2 4 3 998244353 1 2 2 3 1 2 4 6 998244353 1 2 2 3 1 2 3 4 2 3 1 2
output:
10 14 24 24
result:
ok 4 lines
Test #2:
score: -100
Time Limit Exceeded
input:
100 14 0 332974091 7 0 860384617 38 0 721801273 20 0 905563207 15 0 665595113 19 0 315971339 37 10 381449743 20 25 20 25 20 25 20 25 20 25 20 25 20 25 20 25 20 25 20 25 33 7 891399043 7 17 6 16 25 32 25 31 16 25 25 32 17 30 35 0 134186387 43 4 344440849 14 26 26 29 14 26 14 29 44 3 520502371 5 8 5 8...