CSES - HIIT Open 2019 - Results
Submission details
Task:Grid Paths
Sender:bigint bugaa
Submission time:2019-05-25 11:20:55 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.02 sdetails

Code

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll MOD = (int)1e9 + 7;

const int N = 111;
ll res[N][N];
ll val[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	res[1][1] = 1;
	for (int y = 0; y < n; ++y) {
		for (int x = 0; x < n; ++x) {
			cin >> val[y+1][x+1];
			if (y > 0 || x > 0) {
				res[y+1][x+1] = (res[y][x+1] + res[y+1][x]) % MOD;
			}
		}
	}
	ll ans = 0;
	for (int y = 0; y < n; ++y) {
		for (int x = 0; x < n; ++x) {
			ll mult = (res[y+1][x+1] * res[n-y][n-x]) % MOD;
			ans += (mult * val[y+1][x+1]) % MOD;
		}
	}
	ans %= MOD;
	cout << ans << '\n';
}

Test details

Test 1

Verdict: ACCEPTED

input
100
606755118 96655535 664126532 4...

correct output
530182530

user output
530182530