CSES - HIIT Open 2019 - Results
Submission details
Task:Grid Paths
Sender:Piltit
Submission time:2019-05-25 12:49:06 +0300
Language:Python3
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.07 sdetails

Code

n = int(input())
v = []

for i in range(n):
	v.extend(list(map(int, input().split())))


e = [0 for i in range(101010)]

for i in range(n ** 2):
	if i % n:
		if i >= n:
			e[i] = e[i - 1] + e[i - n]
		else:
			e[i] = e[i - 1]
	elif i >= n:
		e[i] = e[i - n]
	else:
		e[i] = 1

d = [0 for i in range(101010)]

for i in range(n ** 2):
	if i % n:
		if i >= n:
			d[i] = d[i - 1] + d[i - n] + e[i] * v[i]
		else:
			d[i] = d[i - 1] + e[i] * v[i]
	else:
		if i >= n:
			d[i] = d[i - n] + e[i] * v[i]
		else:
			d[i] = e[i] * v[i]

print(d[n ** 2 - 1] % int(1e9 + 7))

Test details

Test 1

Verdict: ACCEPTED

input
100
606755118 96655535 664126532 4...

correct output
530182530

user output
530182530