CSES - Putka Open 2015 – 1/6 - Results
Submission details
Task:Lähetit
Sender:
Submission time:2015-07-18 13:59:53 +0300
Language:Python2
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.07 s1details
#20.08 s1details
#30.11 s1details
#40.08 s1details
#50.11 s1details
#60.10 s2details
#70.09 s2details
#80.09 s2details
#90.09 s2details
#100.07 s2details
#110.10 s3details
#120.09 s3details
#130.09 s3details
#140.10 s3details
#150.10 s3details

Code

import sys
import math
import itertools
from collections import defaultdict

n, k = map(int, sys.stdin.readline().rstrip().split())

if n == 1:
	print n
	sys.exit()
if n == 2:
	if k > 1:
		print "QAQ"
	else:
		print "1 2"
	sys.exit()


res = [-1]*n

start1 = 1
start2 = int(math.ceil(n/2.0)) + 1
#if start2 - 2 < k:
#	print "QAQ"
#	sys.exit()

if n % 2 == 1:
	insertStart1 = True
else:
	insertStart1 = False

for i in xrange(n):
	if insertStart1:
		res[i] = start1
		start1 += 1
	else:
		res[i] = start2
		start2 += 1
	insertStart1 = not insertStart1

mindif = min([abs(res[i] - res[i + 1]) for i in xrange(n - 1)])
if mindif >= k:
	print " ".join(map(str, res))
else:
	print "QAQ"

# 1 4 2 5 3 6
# 2 5 1 4 6 3

# 1 5 2 6 3 7 4

# 1 5 2 6 3 7 4 8
# 5 1 6 2 7 3 8 4







Test details

Test 1

Group: 1

Verdict:

input
5 2

correct output
240

user output
1 4 2 5 3

Test 2

Group: 1

Verdict:

input
5 4

correct output
2728

user output
QAQ

Test 3

Group: 1

Verdict:

input
5 6

correct output
1960

user output
QAQ

Test 4

Group: 1

Verdict:

input
5 8

correct output
32

user output
QAQ

Test 5

Group: 1

Verdict:

input
5 10

correct output
0

user output
QAQ

Test 6

Group: 2

Verdict:

input
10 4

correct output
1809464

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

Test 7

Group: 2

Verdict:

input
10 8

correct output
209594075

user output
QAQ

Test 8

Group: 2

Verdict:

input
10 12

correct output
811277399

user output
QAQ

Test 9

Group: 2

Verdict:

input
10 16

correct output
17275136

user output
QAQ

Test 10

Group: 2

Verdict:

input
10 20

correct output
0

user output
QAQ

Test 11

Group: 3

Verdict:

input
100 40

correct output
126883191

user output
51 1 52 2 53 3 54 4 55 5 56 6 ...

Test 12

Group: 3

Verdict:

input
100 80

correct output
785497039

user output
QAQ

Test 13

Group: 3

Verdict:

input
100 120

correct output
324216296

user output
QAQ

Test 14

Group: 3

Verdict:

input
100 160

correct output
895190039

user output
QAQ

Test 15

Group: 3

Verdict:

input
100 200

correct output
0

user output
QAQ