|
|
back to boardSTACK OVERFLOW??? Posted by RAVEman 19 Mar 2007 16:14 How can this algo get Stack overflow(test 12)? #include <string> #include <vector> #include<iostream> #include<queue> using namespace std; struct Pair{ int a,b; }; vector<int> res; int n,s; int a[1111][1111]; void dfs(int ver){ for(int i=0;i<n;i++) if(ver!=i && !a[ver][i]){ a[ver][i]=1; dfs(i); } res.push_back(ver); } int main(){ cin>>n>>s; for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j]; dfs(s-1); reverse(res.begin(),res.end()); for(int i=1;i<res.size();i++) cout<<res[i-1]+1<<" "<<res[i]+1<<endl; system("pause"); return 0; } Re: STACK OVERFLOW??? Use #pragma comment(linker, "/STACK:16777216") |
|
|