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-11 11:29:53
Language:Python3
Status:READY
Score:14

Feedback

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

Test results

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

Code

import math
from array import array

# 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.extend([x == '*' for x in line])

# debug
if desired_trees > math.sqrt(height*width):
    a = 1/0

# Create index
index = []
for i in range(width*height):
    this = 0
    y, x = divmod(i, width)
    if field[i]:
        this = 1
    if y > 0:
        this += index[i-width]
    if x > 0:
        this += index[i-1]
    if y > 0 and x > 0:
        this -= index[i-width-1]
    index.append(this)
#index = array('I', index) # use array instead of list for sake of speed

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

options = 0
min_min_size = math.ceil(math.sqrt(desired_trees))
for y in range(height):
    min_size = min_min_size
    for x in range(width):
        max_size = min(height-y, width-x)
        a = min_size
        for size in range(a, 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
            else:
                min_size = size - 1

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: RUNTIME ERROR

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

correct output
288

view   save

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    a = 1/0
ZeroDivisionError: division by zero

Test 9

Group: 2

Verdict: RUNTIME ERROR

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

correct output
786

view   save

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    a = 1/0
ZeroDivisionError: division by zero

Test 10

Group: 2

Verdict: RUNTIME ERROR

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

correct output
1763

view   save

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    a = 1/0
ZeroDivisionError: division by zero

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: RUNTIME ERROR

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

correct output
1849

view   save

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    a = 1/0
ZeroDivisionError: division by zero

Test 14

Group: 3

Verdict: RUNTIME ERROR

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

correct output
2665

view   save

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    a = 1/0
ZeroDivisionError: division by zero

Test 15

Group: 3

Verdict: RUNTIME ERROR

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

correct output
5587

view   save

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    a = 1/0
ZeroDivisionError: division by zero