今天做题的时候,提交的代码 内存超限了,以前没怎么遇到过这种情况。本人刚开始学习此类知识,最近刚开始刷题,请大家指点。
题目 HDU-4612
(https://acm.hdu.edu.cn/showproblem.php?pid=4612)
#include
#include
#include
#include
#include
using namespace std;
vector<int> Map[200001];//原图
vector<int> edge[200001];//缩点图
mapint,int>,bool> bridge;//记录桥
int ans[200001];//记录边双联通分量
int dfn[200001];//时间戳
int low[200001];//回溯值
bool flag[200001];//标记
int cnt=0,cntb=0,D=0;
int d[200001];//表示路径的长度
int n,m;
void tarjan(int u,int f)// tarjan 求出桥,用bridge记录桥的两个端点
{
cnt++;
dfn[u]=cnt;
low[u]=cnt;
for(int i=0;i

上网查了一下,网上没有针对性的解答,不知道哪里有问题
希望大家能指点出错误或提出一些建议
果断改成heap把,用malloc 申请堆上内存
tarjan递归有没有可能死循环?
改成heap