Exception thrown at saving 0070 x008C4F40: 0xC0000005: an access violation occurred while writing to the location 0x00000000

-sharpinclude <algorithm>
-sharpinclude <bitset>
-sharpinclude <cassert>
-sharpinclude <cmath>
-sharpinclude <cstdio>
-sharpinclude <cstdlib>
-sharpinclude <cstring>
-sharpinclude <functional>
-sharpinclude <iomanip>
-sharpinclude <iostream>
-sharpinclude <list>
-sharpinclude <map>
-sharpinclude <queue>
-sharpinclude <set>
-sharpinclude <sstream>
-sharpinclude <stack>
-sharpinclude <string>
-sharpinclude <vector>


using namespace std;
typedef struct A node;
struct A {
    int v;//
    int x;
    int y;
};
    node tmp[101];
vector<node> edge[101];//edge[i]i
int last=0;//
bool visited[100] = { false };
void dfs(int now,int d) {
    visited[now] = true;
    if (tmp[now].x >= (50 - d) || tmp[now].x <= (d - 50) || tmp[now].y >= (50 - d) || tmp[now].y <= (d - 50)) {
        cout << "Yes" << endl;
        last = 1;
        return;
    }
    for (auto iter = edge[now].begin(); iter != edge[now].end(); iterPP) {
        if (!visited[(*iter).v]) {
            dfs((*iter).v,d);
        }
    }
}
int dis(int x, int y) {
    return x * x + y * y;
}
int main() {
    int n, d;
    cin >> n >> d;//nd
    int D = d * d;
    for (int i =1 ; i <= n; iPP) {
        tmp[i].v = i;
        cin >> tmp[i].x >> tmp[i].y;    
    }
    tmp[0].v = 0;//0
    tmp[0].x = 0;
    tmp[0].y = 0;
    for(int i=0;i<=n;iPP)
        for (int j = 0; i <= n; jPP)//
        {
            if (dis(tmp[i].x - tmp[j].x, tmp[i].y - tmp[j].y) <= D) {
                edge[i].push_back(tmp[j]);
                edge[j].push_back(tmp[i]);
            }
        }
    for (auto iter = edge[0].begin(); iter != edge[0].end(); iterPP) {
        memset((void*)visited, 0, sizeof(visited));
        dfs((*iter).v,d);
        if (last == 1) break;
    }
    if (last == 0) {
        cout << "No" << endl;
    }
    system("pause");
    return 0;
}

the problem is that there is a point in the middle of a 100 100 square as the origin. Enter the coordinates of n points and the distance to the maximum movement, and ask if you can jump to the edge of the square
. If you encounter this kind of problem for the first time, I don"t know how to change it

.
CPP c
Jan.27,2022

it is estimated that the subscript is out of bounds. You add a breakpoint, click debug, and you will immediately know which sentence of code has gone wrong.

Menu