CSES - Putka Open 2015 – 4/6 - Results
Submission details
Task:Taulukot
Sender:
Submission time:2015-10-11 15:51:36 +0300
Language:Python3
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED26
#2ACCEPTED29
#3ACCEPTED45
Test results
testverdicttimegroup
#1ACCEPTED0.08 s1details
#2ACCEPTED0.07 s1details
#3ACCEPTED0.08 s1details
#4ACCEPTED0.09 s1details
#5ACCEPTED0.08 s1details
#6ACCEPTED0.08 s2details
#7ACCEPTED0.09 s2details
#8ACCEPTED0.09 s2details
#9ACCEPTED0.07 s2details
#10ACCEPTED0.09 s2details
#11ACCEPTED0.23 s3details
#12ACCEPTED0.26 s3details
#13ACCEPTED0.26 s3details
#14ACCEPTED0.24 s3details
#15ACCEPTED0.24 s3details

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)
eka = []
toka = []

while n > 0:
    k = n
    while not seula[n + k]:
        k -= 1
    for x in range(k, n + 1):
        eka.append(x)
    for x in range(n, k - 1, -1):
        toka.append(x)
    n = k - 1
print(' '.join(str(x) for x in eka))
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: ACCEPTED

input
4

correct output
1 2 3 4 
2 1 4 3 

user output
3 4 1 2
4 3 2 1

Test 3

Group: 1

Verdict: ACCEPTED

input
5

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

user output
2 3 4 5 1
5 4 3 2 1

Test 4

Group: 1

Verdict: ACCEPTED

input
8

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

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

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
8 9 6 7 2 3 4 5 1
9 8 7 6 5 4 3 2 1

Test 6

Group: 2

Verdict: ACCEPTED

input
77

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

user output
74 75 76 77 66 67 68 69 70 71 ...

Test 7

Group: 2

Verdict: ACCEPTED

input
70

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

user output
69 70 63 64 65 66 67 68 51 52 ...

Test 8

Group: 2

Verdict: ACCEPTED

input
72

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

user output
67 68 69 70 71 72 65 66 63 64 ...

Test 9

Group: 2

Verdict: ACCEPTED

input
86

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

user output
81 82 83 84 85 86 77 78 79 80 ...

Test 10

Group: 2

Verdict: ACCEPTED

input
68

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

user output
63 64 65 66 67 68 51 52 53 54 ...

Test 11

Group: 3

Verdict: ACCEPTED

input
90764

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

user output
90759 90760 90761 90762 90763 ...

Test 12

Group: 3

Verdict: ACCEPTED

input
97976

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

user output
97955 97956 97957 97958 97959 ...

Test 13

Group: 3

Verdict: ACCEPTED

input
96762

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

user output
96751 96752 96753 96754 96755 ...

Test 14

Group: 3

Verdict: ACCEPTED

input
94823

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

user output
94820 94821 94822 94823 94800 ...

Test 15

Group: 3

Verdict: ACCEPTED

input
91479

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

user output
91478 91479 91476 91477 91458 ...