D
D
dalbio2020-06-20 16:22:21
visual studio
dalbio, 2020-06-20 16:22:21

Why can't I run the code in visual studio?

#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  long long matr[1001][1001];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      matr[i][j] = c == '*' ? LLONG_MAX : 0;
    }
  }
  //queue<pair<int, int>>q;
  //q.push({ 0, 0 });
  const int di[2] = { 0,1 };
  const int dj[2] = { 1,0 };
  while (0) {
    pair<int, int> t;
    //t = q.front();
    //q.pop();
    int i = t.first;
    int j = t.second;
    if (i == n - 1 && j == n - 1) continue;
    for (int t = 0; t < 2; t++) {
      if (i + di[t] < n && j + dj[t] < n && matr[i+di[t]][j+dj[t]]!=LLONG_MAX) {
        matr[i + di[t]][j + dj[t]] += matr[i][j];
        matr[i + di[t]][j + dj[t]] %= mod;
        //q.push({ i + di[t],j + dj[t] });
      }
    }
  }
  cout << matr[n - 1][n - 1];
}

Input example:

4
....
.*..
...*
*...

In online editor, code run in visual studio community
throws Unhandled exception at 0x00D83299 0xC00000FD: Stack overflow.
And when launched without debugging, it exited with the code -1073741571.
And the problem is in the code, because other code is running.
I will be grateful for help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Pavlov, 2020-06-20
@dalbio

Look at which line debugging stops

D
dalbio, 2020-06-20
@dalbio

In general, the problem was that for some reason such a matrix long long matr[1001][1001]; not allowed, but
long long matr[100][100]; can.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question