CSES - Putka Open 2015 – 4/6 - Results
Submission details
Task:Taulukot
Sender:
Submission time:2015-10-11 15:18:15 +0300
Language:Python3
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.08 s1details
#20.08 s1details
#30.08 s1details
#40.07 s1details
#5ACCEPTED0.08 s1details
#60.08 s2details
#70.08 s2details
#80.08 s2details
#90.09 s2details
#100.09 s2details
#11--3details
#12--3details
#13--3details
#14--3details
#15--3details

Code

n = int(input())

def eras(n):
    e = [False, False] + ([True] * (n - 1))
    for i in range(2, n + 1):
        if e[i]:
            for j in range(2 * i, n + 1, i):
                e[j] = False
    return e

seula = eras(2 * n)
tarjolla = set(range(1, n + 1))
toka = []
# x = 1, 2, 3 eli ekan taulukon jarjestys
# toka = [6, 3, ...] eli tokan taulukon järjestys
for x in range(1, n + 1):
    for t in tarjolla:
        summa = x + t
        if seula[summa]:
            toka.append(t)
            tarjolla.remove(t)
            break
    else:
        # vaihdetaan sopivan kanssa toka-taulukosta
        # aiemman pitaa sopia tahan ja tarjolla'sta pitaa loytya sopiva aiempaan
        for i in range(x - 1):
            if not seula[toka[i] + x]:
                continue
            for t in tarjolla:
                if seula[i + 1 + t]:
                    toka.append(toka[i])
                    toka[i] = t
                    trajolla.remove(t)
                    break
            else:
                continue
            break
print(' '.join(str(x) for x in range(1, n + 1)))
print(' '.join(str(x) for x in toka))

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
1

correct output


user output
1
1

Test 2

Group: 1

Verdict:

input
4

correct output
1 2 3 4 
2 1 4 3 

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 33, in <module>
    trajolla.remove(t)
NameError: name 'trajolla' is not defined

Test 3

Group: 1

Verdict:

input
5

correct output
1 2 3 4 5 
1 5 4 3 2 

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 33, in <module>
    trajolla.remove(t)
NameError: name 'trajolla' is not defined

Test 4

Group: 1

Verdict:

input
8

correct output
1 2 3 4 5 6 7 8 
2 1 4 3 8 7 6 5 

user output
1 2 3 4 5 6 7 8
1 3 2 7 6 5 4

Test 5

Group: 1

Verdict: ACCEPTED

input
9

correct output
1 2 3 4 5 6 7 8 9 
1 5 4 3 2 7 6 9 8 

user output
1 2 3 4 5 6 7 8 9
1 3 2 7 6 5 4 9 8

Test 6

Group: 2

Verdict:

input
77

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 33, in <module>
    trajolla.remove(t)
NameError: name 'trajolla' is not defined

Test 7

Group: 2

Verdict:

input
70

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 33, in <module>
    trajolla.remove(t)
NameError: name 'trajolla' is not defined

Test 8

Group: 2

Verdict:

input
72

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 33, in <module>
    trajolla.remove(t)
NameError: name 'trajolla' is not defined

Test 9

Group: 2

Verdict:

input
86

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 33, in <module>
    trajolla.remove(t)
NameError: name 'trajolla' is not defined

Test 10

Group: 2

Verdict:

input
68

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 33, in <module>
    trajolla.remove(t)
NameError: name 'trajolla' is not defined

Test 11

Group: 3

Verdict:

input
90764

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Test 12

Group: 3

Verdict:

input
97976

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Test 13

Group: 3

Verdict:

input
96762

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Test 14

Group: 3

Verdict:

input
94823

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Test 15

Group: 3

Verdict:

input
91479

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)