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

Compiler report

input/code.cpp: In function 'll taikaluku(ll, ll)':
input/code.cpp:13:12: warning: variable 'fuck' set but not used [-Wunused-but-set-variable]
       bool fuck = false;
            ^~~~

Code

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

ll mestari = 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;
      bool fuck = false;
      if(i > 0) { sum += g[i-1][j]; fuck = true; }
      if(j > 0) { sum += g[i][j-1]; fuck = true; }
      if(i == 0 || j == 0) { g[i][j] = 1; }
      else { g[i][j] = sum; }
      g[i][j] %= mestari;
    }
  }
  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);
      je[i][j] %= mestari;
    }
  }
  //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]))%mestari;
    }
  }
  if(sum < 0) sum += mestari;
  cout << sum << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
100
606755118 96655535 664126532 4...

correct output
530182530

user output
530182530