Code Submission Evaluation System Login

Datatähti 2016 alku

Start:2015-09-28 00:00:00
End:2015-10-12 00:00:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2016 alku - Results
History
2015-10-11 15:47:3614
2015-10-11 15:40:160
2015-10-11 12:12:450
2015-10-11 12:08:580
2015-10-11 12:07:090
2015-10-11 12:04:440
2015-10-11 12:02:300
2015-10-11 11:56:110
2015-10-11 11:53:420
2015-10-11 11:35:210
2015-10-11 11:29:5314
2015-10-11 11:27:5214
2015-10-11 11:24:550
2015-10-11 11:23:080
2015-10-11 11:15:100
2015-10-01 19:04:2614
2015-10-01 19:03:250
2015-10-01 18:49:5114
Task:Tontti
Sender:felixbade
Submission time:2015-10-01 18:49:51
Language:Python3
Status:READY
Score:14

Feedback

groupverdictscore
#1ACCEPTED14
#2TIME LIMIT EXCEEDED0
#3TIME LIMIT EXCEEDED0

Test results

testverdicttime (s)group
#1ACCEPTED0.09 / 1.001details
#2ACCEPTED0.08 / 1.001details
#3ACCEPTED0.08 / 1.001details
#4ACCEPTED0.08 / 1.001details
#5ACCEPTED0.08 / 1.001details
#6TIME LIMIT EXCEEDED-- / 1.002details
#7TIME LIMIT EXCEEDED-- / 1.002details
#8TIME LIMIT EXCEEDED-- / 1.002details
#9TIME LIMIT EXCEEDED-- / 1.002details
#10TIME LIMIT EXCEEDED-- / 1.002details
#11TIME LIMIT EXCEEDED-- / 1.003details
#12TIME LIMIT EXCEEDED-- / 1.003details
#13TIME LIMIT EXCEEDED-- / 1.003details
#14TIME LIMIT EXCEEDED-- / 1.003details
#15TIME LIMIT EXCEEDED-- / 1.003details

Code

import math

# Parse input
line = input().split()
height = int(line[0])
width = int(line[1])
desired_trees = int(line[2])

field = []
for y in range(height):
    line = input()
    field.append([x == '*' for x in line])

# Create index
index = []
for y in range(height):
    index_line = []
    for x in range(width):
        this = 0
        if field[y][x]:
            this = 1
        if y > 0:
            this += index[y-1][x]
        if x > 0:
            this += index_line[x-1]
        if y > 0 and x > 0:
            this -= index[y-1][x-1]
        index_line.append(this)
    index.append(index_line)

# Calculate
def trees_in(x1, y1, size):
    x2 = x1 + size - 1
    y2 = y1 + size - 1
    if x1 == 0 and y1 == 0:
        return index[y2][x2]
    elif x1 == 0:
        return index[y2][x2] - index[y1-1][x2]
    elif y1 == 0:
        return index[y2][x2] - index[y2][x1-1]
    else:
        return index[y2][x2] - index[y1-1][x2] - index[y2][x1-1] + index[y1-1][x1-1]

options = 0
min_size = math.ceil(math.sqrt(desired_trees))
for y in range(height):
    for x in range(width):
        max_size = min(height-y, width-x)
        for size in range(min_size, max_size+1):
            trees = trees_in(x, y, size)
            if trees == desired_trees:
                options += 1
            elif trees > desired_trees:
                # bigger area can't have less trees
                break

print(options)

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
10 10 1
......*...
.......*..
*..*....*.
*....*....
...
view   save

correct output
94

view   save

user output
94

view   save

Test 2

Group: 1

Verdict: ACCEPTED

input
10 10 5
**********
**********
**********
**********
...
view   save

correct output
0

view   save

user output
0

view   save

Test 3

Group: 1

Verdict: ACCEPTED

input
10 10 10
**...*...*
*..*.**.*.
...**.*..*
*...**.*..
...
view   save

correct output
4

view   save

user output
4

view   save

Test 4

Group: 1

Verdict: ACCEPTED

input
10 10 5
****......
*.*.**..**
....*.*..*
...*.***..
...
view   save

correct output
16

view   save

user output
16

view   save

Test 5

Group: 1

Verdict: ACCEPTED

input
10 10 2
**.***..*.
...*.*....
.***.*...*
***.***..*
...
view   save

correct output
30

view   save

user output
30

view   save

Test 6

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
500 500 1
.................................
view   save

correct output
9552040

view   save

user output
(empty)

Test 7

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
500 500 5
.................................
view   save

correct output
1536063

view   save

user output
(empty)

Test 8

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
500 500 25000
**...*...**..*.*..*.**.*..*.*....
view   save

correct output
288

view   save

user output
(empty)

Test 9

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
500 500 12500
**.**.*..*...*.**...*.***........
view   save

correct output
786

view   save

user output
(empty)

Test 10

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
500 500 5000
.*.*.**..*.*.**.**..*..**...*....
view   save

correct output
1763

view   save

user output
(empty)

Test 11

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
2000 2000 1
.................................
view   save

correct output
489611392

view   save

user output
(empty)

Test 12

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
2000 2000 5
.................................
view   save

correct output
120725884

view   save

user output
(empty)

Test 13

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
2000 2000 400000
..*..**.**.**.*.***...**.*..**...
view   save

correct output
1849

view   save

user output
(empty)

Test 14

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
2000 2000 200000
***.*....*.*..*....**..*..*.*....
view   save

correct output
2665

view   save

user output
(empty)

Test 15

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
2000 2000 80000
**.**...*.***.**....**.*....*....
view   save

correct output
5587

view   save

user output
(empty)