问题描述
调试停止在读取代码中,问题是什么以及如何解决,谢谢
debug stopped at code in read, what's the problem and how to address, thanks
#include< iostream>
#include< vector>
#include< queue>
#include<iostream>
#include<vector>
#include<queue>
int main()
{
int m,n;
std :: cin>> m>> n;
while(m!= - 1&& n!= - 1)
{
;的std ::矢量< INT> vertices [40000];
std :: queue< int> que;
int dist [40000];
int pre [40000];
memset(dist,-1,sizeof(dist));
$
int xmax = 0,xmin = 200,ymax = 0,ymin = 200;
for(int i = 0; i< m; i ++)
{
int x,y,dir ,len;
std :: cin>> x>> y>> dir>> len;
xmax = xmax> X ? xmax:x;
xmin = xmin< X ? xmin:x;
ymax = ymax>你? ymax:y;
ymin = ymin< X ? ymin:y;
}
int row = ymax - ymin,col = xmax - xmin;
dist [row * col] = 0;
for(int i = 0; i< n; i ++)
{
int x,y,dir;
std :: cin>> x>> y>> dir;
if(dir == 0)
{
if(y< ymax&& y> ymin)
{
; vertices [(y - ymin)* col + x - xmin] .push_back((y - ymin - 1)* col + x - xmin);
; vertices [(y - ymin - 1)* col + x - xmin] .push_back((y - ymin)* col + x - xmin);
}
else if(y == ymax)
{
  ; vertices [(row - 1)* col + x - xmin] .push_back(row * col);
vertices [row * col] .push_back((row - 1)* col + x - xmin);
}
else if(y == ymin)
{
vertices [x - xmin] .push_back(row * col);
vertices [row * col] .push_back(x - xmin);
}
}
if(dir == 1)
{
if(x> xmin&& x< xmax)
{
vertices [(y - ymin)* col + x - xmin ] .push_back((y - ymin)* col + x - xmin - 1);
vertices [ (y - ymin)* col + x - xmin - 1] .push_back((y - ymin)* col + x - xmin);
}
if(x == xmax)
{
  ; vertices [(y - ymin)* col + col] .push_back(row * col);
vertices [row * col] .push_back((y - ymin)* col + col);
}
if(x == xmin)
{
vertices [(y-ymin)* col] .push_back(row * col);
vertices [row * col] .push_back((y - ymin)* col);
}
}
}
float nex,ney;
std :: cin>> nex>> ney;
$
int nepos =((int)floor(nex) - 1)+((int)floor(ney) - 1)* col;
que.push(row * col);
while(!que.empty())
{
int tmp = que.front();
que.pop();
  ; for(int j = 0; j< vertices [tmp] .size(); j ++)
if(dist [vertices [tmp] [j]] == -1 || dist [tmp] + 1< dist [vertices [tmp] [j]])
{
dist [vertices [tmp] [j]] = dist [tmp] + 1;
pre [vertices [tmp] [j]] = tmp;
que.push(vertices [tmp] [j]);
}
}
std :: cout<< dist [nepos]<< std :: endl;
}
}
int main()
{
int m, n;
std::cin >> m >> n;
while(m!=-1&&n!=-1)
{
std::vector<int> vertices[40000];
std::queue<int> que;
int dist[40000];
int pre[40000];
memset(dist, -1, sizeof(dist));
int xmax=0, xmin=200, ymax=0, ymin=200;
for (int i = 0;i<m;i++)
{
int x, y, dir, len;
std::cin >> x >> y >> dir >> len;
xmax = xmax > x ? xmax : x;
xmin = xmin < x ? xmin : x;
ymax = ymax > y ? ymax : y;
ymin = ymin < x ? ymin : y;
}
int row = ymax - ymin, col = xmax - xmin;
dist[row*col] = 0;
for(int i=0;i<n;i++)
{
int x, y, dir;
std::cin >> x >> y >> dir;
if (dir == 0)
{
if(y<ymax&&y>ymin)
{
vertices[(y - ymin)*col + x - xmin].push_back((y - ymin - 1)*col + x - xmin);
vertices[(y - ymin - 1)*col + x - xmin].push_back((y - ymin)*col + x - xmin);
}
else if(y==ymax)
{
vertices[(row - 1)*col + x - xmin].push_back(row*col);
vertices[row*col].push_back((row - 1)*col + x - xmin);
}
else if(y==ymin)
{
vertices[x - xmin].push_back(row*col);
vertices[row*col].push_back(x - xmin);
}
}
if(dir==1)
{
if (x > xmin&&x < xmax)
{
vertices[(y - ymin)*col + x - xmin].push_back((y - ymin)*col + x - xmin - 1);
vertices[(y - ymin)*col + x - xmin - 1].push_back((y - ymin)*col + x - xmin);
}
if(x==xmax)
{
vertices[(y - ymin)*col + col].push_back(row*col);
vertices[row*col].push_back((y - ymin)*col + col);
}
if (x == xmin)
{
vertices[(y - ymin)*col].push_back(row*col);
vertices[row*col].push_back((y - ymin)*col);
}
}
}
float nex, ney;
std::cin >> nex >> ney;
int nepos = ((int)floor(nex) - 1)+((int)floor(ney) - 1)*col;
que.push(row*col);
while(!que.empty())
{
int tmp = que.front();
que.pop();
for (int j = 0; j < vertices[tmp].size(); j++)
if (dist[vertices[tmp][j]] == -1 || dist[tmp] + 1 < dist[vertices[tmp][j]])
{
dist[vertices[tmp][j]] = dist[tmp] + 1;
pre[vertices[tmp][j]] = tmp;
que.push(vertices[tmp][j]);
}
}
std::cout << dist[nepos] << std::endl;
}
}
推荐答案
#include< iostream>
#include< vector>
#include< queue>
#include<iostream>
#include<vector>
#include<queue>
int main()
{
int m,n;
std :: cin>> m>> n;
while(m!= - 1&& n!= - 1)
{
;的std ::矢量< INT> vertices [40000];
std :: queue< int> que;
int dist [40000];
int pre [40000];
memset(dist,-1,sizeof(dist));
$
int xmax = 0,xmin = 200,ymax = 0,ymin = 200;
for(int i = 0; i< m; i ++)
{
int x,y,dir ,len;
std :: cin>> x>> y>> dir>> len;
xmax = xmax> X ? xmax:x;
xmin = xmin< X ? xmin:x;
ymax = ymax>你? ymax:y;
ymin = ymin< X ? ymin:y;
}
int row = ymax - ymin,col = xmax - xmin;
dist [row * col] = 0;
for(int i = 0; i< n; i ++)
{
int x,y,dir;
std :: cin>> x>> y>> dir;
if(dir == 0)
{
if(y< ymax&& y> ymin)
{
; vertices [(y - ymin)* col + x - xmin] .push_back((y - ymin - 1)* col + x - xmin);
; vertices [(y - ymin - 1)* col + x - xmin] .push_back((y - ymin)* col + x - xmin);
}
else if(y == ymax)
{
  ; vertices [(row - 1)* col + x - xmin] .push_back(row * col);
vertices [row * col] .push_back((row - 1)* col + x - xmin);
}
else if(y == ymin)
{
vertices [x - xmin] .push_back(row * col);
vertices [row * col] .push_back(x - xmin);
}
}
if(dir == 1)
{
if(x> xmin&& x< xmax)
{
vertices [(y - ymin)* col + x - xmin ] .push_back((y - ymin)* col + x - xmin - 1);
vertices [ (y - ymin)* col + x - xmin - 1] .push_back((y - ymin)* col + x - xmin);
}
if(x == xmax)
{
  ; vertices [(y - ymin)* col + col] .push_back(row * col);
vertices [row * col] .push_back((y - ymin)* col + col);
}
if(x == xmin)
{
vertices [(y-ymin)* col] .push_back(row * col);
vertices [row * col] .push_back((y - ymin)* col);
}
}
}
float nex,ney;
std :: cin>> nex>> ney;
$
int nepos =((int)floor(nex) - 1)+((int)floor(ney) - 1)* col;
que.push(row * col);
while(!que.empty())
{
int tmp = que.front();
que.pop();
  ; for(int j = 0; j< vertices [tmp] .size(); j ++)
if(dist [vertices [tmp] [j]] == -1 || dist [tmp] + 1< dist [vertices [tmp] [j]])
{
dist [vertices [tmp] [j]] = dist [tmp] + 1;
pre [vertices [tmp] [j]] = tmp;
que.push(vertices [tmp] [j]);
}
}
std :: cout<< dist [nepos]<< std :: endl;
}
}
int main()
{
int m, n;
std::cin >> m >> n;
while(m!=-1&&n!=-1)
{
std::vector<int> vertices[40000];
std::queue<int> que;
int dist[40000];
int pre[40000];
memset(dist, -1, sizeof(dist));
int xmax=0, xmin=200, ymax=0, ymin=200;
for (int i = 0;i<m;i++)
{
int x, y, dir, len;
std::cin >> x >> y >> dir >> len;
xmax = xmax > x ? xmax : x;
xmin = xmin < x ? xmin : x;
ymax = ymax > y ? ymax : y;
ymin = ymin < x ? ymin : y;
}
int row = ymax - ymin, col = xmax - xmin;
dist[row*col] = 0;
for(int i=0;i<n;i++)
{
int x, y, dir;
std::cin >> x >> y >> dir;
if (dir == 0)
{
if(y<ymax&&y>ymin)
{
vertices[(y - ymin)*col + x - xmin].push_back((y - ymin - 1)*col + x - xmin);
vertices[(y - ymin - 1)*col + x - xmin].push_back((y - ymin)*col + x - xmin);
}
else if(y==ymax)
{
vertices[(row - 1)*col + x - xmin].push_back(row*col);
vertices[row*col].push_back((row - 1)*col + x - xmin);
}
else if(y==ymin)
{
vertices[x - xmin].push_back(row*col);
vertices[row*col].push_back(x - xmin);
}
}
if(dir==1)
{
if (x > xmin&&x < xmax)
{
vertices[(y - ymin)*col + x - xmin].push_back((y - ymin)*col + x - xmin - 1);
vertices[(y - ymin)*col + x - xmin - 1].push_back((y - ymin)*col + x - xmin);
}
if(x==xmax)
{
vertices[(y - ymin)*col + col].push_back(row*col);
vertices[row*col].push_back((y - ymin)*col + col);
}
if (x == xmin)
{
vertices[(y - ymin)*col].push_back(row*col);
vertices[row*col].push_back((y - ymin)*col);
}
}
}
float nex, ney;
std::cin >> nex >> ney;
int nepos = ((int)floor(nex) - 1)+((int)floor(ney) - 1)*col;
que.push(row*col);
while(!que.empty())
{
int tmp = que.front();
que.pop();
for (int j = 0; j < vertices[tmp].size(); j++)
if (dist[vertices[tmp][j]] == -1 || dist[tmp] + 1 < dist[vertices[tmp][j]])
{
dist[vertices[tmp][j]] = dist[tmp] + 1;
pre[vertices[tmp][j]] = tmp;
que.push(vertices[tmp][j]);
}
}
std::cout << dist[nepos] << std::endl;
}
}
I已经解决了,没关系
I've addressed it, never mind
这篇关于访问冲突读取位置0xFFFFFFEF。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!