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-09-29 17:03:3514
2015-09-29 17:01:560
2015-09-29 16:31:390
2015-09-29 16:20:2514
2015-09-29 16:18:590
2015-09-29 16:05:1614
2015-09-29 15:48:2014
2015-09-29 15:40:0314
2015-09-29 04:20:0314
2015-09-29 04:17:4814
2015-09-29 04:15:220
2015-09-29 04:11:450
2015-09-29 04:06:160
2015-09-29 04:01:360
2015-09-29 03:57:080
2015-09-29 03:51:040
2015-09-29 03:46:420
2015-09-29 03:45:250
2015-09-29 03:44:250
2015-09-29 03:27:1214
2015-09-29 03:23:1214
2015-09-29 03:21:3714
2015-09-29 03:10:390
2015-09-29 02:38:5114
2015-09-29 02:36:0614
2015-09-29 02:12:2814
Task:Tontti
Sender:Ilari
Submission time:2015-09-29 17:03:35
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.08 / 1.001details
#3ACCEPTED0.09 / 1.001details
#4ACCEPTED0.10 / 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

#!/usr/bin/python3
import math
n, m, x = map(int, input().split())
#print(n,m,x)
a=[]
for i in range(0,n):
	a.append(list(map(int, input().replace('.','0').replace('*','1'))))
#a=a.replace('.','0').replace('*','1')


def sumTrees(x,y):
	trees=0
	b=[]
	for i in range(0,y):
		i1=i-1
		b.append([])
		ai=list(a[i])
		for j in range(0,x):
			trees+=ai[j]
			if i>0:
				b[i].append(trees+b[i1][j])
			else:
				b[i].append(trees)
		trees=0
	return b

b=sumTrees(m,n)

#for i in b:
#	print(i)
#for i in range(0,n):
#	ai=a[i]
#	b.append([])
#
#	for j in range(0,m):
#		b[i]=ai[j]
#print(a)


#for i in range(1, limit+1):
#	pass
#@profile

#@profile
def countTrees(x,x1,y,y1,size,x0,y0):
	#trees=0
	if not (x0 or y0):
		trees=b[y+size][x+size]-b[y1][x+size]-b[y+size][x1]+b[y1][x1]
	elif x==0 and y==0:
		trees=b[size][size]
	elif x==0:
		trees=b[y+size][size]-b[y1][size]
	else:
		trees=b[size][x+size]-b[size][x1]

	return trees

def possibleSquares(ny,mx,sqrt):
	if ny<mx:
		limit=ny
	else:
		limit=mx
	return range(sqrt-1,limit)

#print(countTrees(2,0,3))
#answer=0
sqrt=int(math.sqrt(x))
#@profile
def calculate():
	answer=0
	for i in range(0, m):
		mx=m-i
		i1=i-1
		if i==0:
			i0=1
		else:
			i0=0
		for j in range(0,n):
			if j==0:
				j0=1
			else:
				j0=0
			j1=j-1
			#trees = 0
			for k in possibleSquares(n-j,mx, sqrt):
				trees = countTrees(i,i1,j,j1,k,i0,j0)
				if trees > x:
					break
				elif trees == x:
					answer+=1
	return answer
print(calculate())

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)