CSES - Putka Open 2015 – 3/6 - Results
Submission details
Task:Ruudukko
Sender:
Submission time:2015-09-11 22:56:43 +0300
Language:Python3
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED31
#3ACCEPTED57
Test results
testverdicttimegroup
#1ACCEPTED0.09 s1details
#2ACCEPTED0.08 s1details
#3ACCEPTED0.08 s1details
#4ACCEPTED0.08 s1details
#5ACCEPTED0.07 s1details
#6ACCEPTED0.08 s2details
#7ACCEPTED0.09 s2details
#8ACCEPTED0.09 s2details
#9ACCEPTED0.08 s2details
#10ACCEPTED0.07 s2details
#11ACCEPTED0.08 s3details
#12ACCEPTED0.08 s3details
#13ACCEPTED0.10 s3details
#14ACCEPTED0.07 s3details
#15ACCEPTED0.08 s3details

Code

#!/usr/bin/env python3

TILAN_MAX_LEV = 18
TILAN_MAX_KORK = 5 # (5 + väli) per tila

# ruudukko koostuu yhdestä 1-20 reitin tilasta
# ja mahdollisesti yhdestä tai kahdesta isommasta reittitilasta

def tilan_reitit(x, y):
    tila = [[1 for a in range(x)] for b in range(y)]
    for b in range(1, y):
        for a in range(1, x):
            tila[b][a] = tila[b-1][a] + tila[b][a-1]
    return tila

def sopiva_ruudukko(kohdemaara, tilaruudukko):
    paras = 0
    valinta = None
    for y in range(TILAN_MAX_KORK):
        for x in range(TILAN_MAX_LEV):
            if paras < tilaruudukko[y][x] <= kohdemaara:
                paras = tilaruudukko[y][x]
                valinta = (x + 1, y + 1)
    return valinta, paras

def maarita_ruudukot(reitteja):
    tilaruudukko = tilan_reitit(TILAN_MAX_LEV, TILAN_MAX_KORK)
    ruudukot = []
    while reitteja > 20:
        valinta, kattaa = sopiva_ruudukko(reitteja, tilaruudukko)
        reitteja -= kattaa
        ruudukot.append(valinta)
    return (ruudukot, reitteja)

def luo_kentta(ruudukot, jaljella):
    rivit = []
    if jaljella > 0:
        rivit.append('.' * jaljella + '#' * (20 - jaljella))
        rivit.append('.' * 20)

    for x, y in ruudukot:
        rivit.append('.' + 18 * '#' + '.')
        for j in range(y - 1):
            rivit.append('.' * x + '#' * (19 - x) + '.')
        rivit.append('.' * 20)

    while len(rivit) < 20:
        rivit.append(19 * '#' + '.')
    return rivit

def piirra_kentta(kentta):
    for rivi in kentta:
        print(rivi)

def main():
    n = int(input())
    ruudukot, jaljella = maarita_ruudukot(n)
    kentta = luo_kentta(ruudukot, jaljella)
    piirra_kentta(kentta)

if __name__ == '__main__':
    main()

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
2

correct output
....................
.###################
.###################
.###################
.###################
...

user output
..##################
....................
###################.
###################.
###################.
...

Test 2

Group: 1

Verdict: ACCEPTED

input
5

correct output
....................
.################..#
.#################..
.#################..
.##################.
...

user output
.....###############
....................
###################.
###################.
###################.
...

Test 3

Group: 1

Verdict: ACCEPTED

input
7

correct output
....................
.################..#
.#################..
.#################..
.##################.
...

user output
.......#############
....................
###################.
###################.
###################.
...

Test 4

Group: 1

Verdict: ACCEPTED

input
8

correct output
....................
.###################
.###################
.###################
.###################
...

user output
........############
....................
###################.
###################.
###################.
...

Test 5

Group: 1

Verdict: ACCEPTED

input
9

correct output
....................
.###################
.###################
.###################
.###################
...

user output
.........###########
....................
###################.
###################.
###################.
...

Test 6

Group: 2

Verdict: ACCEPTED

input
19

correct output
....................
.############..#####
.#############..####
.#############...###
.##############...##
...

user output
...................#
....................
###################.
###################.
###################.
...

Test 7

Group: 2

Verdict: ACCEPTED

input
32

correct output
....................
.###################
.###################
.###################
.###################
...

user output
....################
....................
.##################.
.......############.
.......############.
...

Test 8

Group: 2

Verdict: ACCEPTED

input
44

correct output
....................
.################..#
.#################..
.#################..
.##################.
...

user output
........############
....................
.##################.
........###########.
........###########.
...

Test 9

Group: 2

Verdict: ACCEPTED

input
76

correct output
....................
.########..######..#
.#########..######..
.#########...#####..
.##########...#####.
...

user output
......##############
....................
.##################.
.....##############.
.....##############.
...

Test 10

Group: 2

Verdict: ACCEPTED

input
93

correct output
....................
.########..##..##..#
.#########..##..##..
.#########...#...#..
.##########...#...#.
...

user output
..##################
....................
.##################.
.............######.
.............######.
...

Test 11

Group: 3

Verdict: ACCEPTED

input
141

correct output
....................
.################..#
.#################..
.#################..
.##################.
...

user output
.....###############
....................
.##################.
................###.
................###.
...

Test 12

Group: 3

Verdict: ACCEPTED

input
422

correct output
....................
.####..##########..#
.#####..##########..
.#####...#########..
.######...#########.
...

user output
..##################
....................
.##################.
............#######.
............#######.
...

Test 13

Group: 3

Verdict: ACCEPTED

input
671

correct output
....................
.#.##########..##..#
....##########..##..
.#...#########...#..
.##...#########...#.
...

user output
......##############
....................
.##################.
..............#####.
..............#####.
...

Test 14

Group: 3

Verdict: ACCEPTED

input
895

correct output
....................
.#.##..##..##..##..#
....##..##..##..##..
.#...#...#...#...#..
.##...#...#...#...#.
...

user output
.###################
....................
.##################.
................###.
................###.
...

Test 15

Group: 3

Verdict: ACCEPTED

input
956

correct output
....................
.#.##..######..##..#
....##..######..##..
.#...#...#####...#..
.##...#...#####...#.
...

user output
....################
....................
.##################.
................###.
................###.
...