ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1176. Hyperchannels

STACK 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???
Posted by ArcSTU Team#01 19 Mar 2007 19:06
Use
#pragma comment(linker, "/STACK:16777216")