CSES - HIIT Open 2019 - Results
Submission details
Task:Grid Paths
Sender:O(n^10)
Submission time:2019-05-25 12:10:25 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.97 sdetails

Code

#include<bits/stdc++.h>
//ULVILAMAFIA&O(n^10)
typedef long long ll;
using namespace std;

ll homo_m = 1e9+7;

ll taikaluku(ll n, ll m) {
  ll g[n][m];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      ll sum = 0;
      if(i > 0) sum += g[i-1][j];
      if(j > 0) sum += g[i][j-1];
      if(sum == 0) { g[i][j] = 1; }
      else { g[i][j] = sum; }
      g[i][j] %= homo_m;
    }
  }
  return g[n-1][m-1];
}

int main() {
  //cout << "DEBUG: " << taikaluku(2,1) << "\n";
  int n; cin >> n;
  ll ss[n][n];
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> ss[i][j];
  ll je[n][n];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      je[i][j] = taikaluku(i+1, j+1) * taikaluku(n-i, n-j);
    }
  }
  //cout << "FUCK\n";
  ll sum = 0;
  //cout << "VAMMAFLAG" << "\n";
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      sum = (sum+(je[i][j]*ss[i][j])%homo_m)%homo_m;
    }
  }
  if(sum < 0) sum += homo_m;
  cout << sum << "\n";
}

Test details

Test 1

Verdict:

input
100
606755118 96655535 664126532 4...

correct output
530182530

user output
980549166