×

# [closed] firescape route WA

 0 lzz......guys help me out....whats wrong in my code eveytime gettting WA...though i have checked for a couple of test cases. #include #include #include #define M 10000007 using namespace std; list frnd[100006];int y=0; int visited[100006]={0};long long int routes,captain=1; int dfs(int a); int main() { int t,a,b,c,i,j,k,l,n,m; scanf("%d",&t); while(t--) { scanf("%d %d",&n,&m); for(i=1;i<=m;i++) { scanf("%d %d",&a,&b); frnd[b].push_back(a); frnd[a].push_back(b); }y=0; for(i=1;i<=n;i++) {if(visited[i]==0){routes++;dfs(i);captain=captain*y;y=0;} } printf("%lld %lld\n",routes%M,captain%M); for(i=1;i<=n;i++){frnd[i].clear();visited[i]=0;}routes=0;captain=1; } return 0; } int dfs(int a) { if(visited[a]==1) return 0; y++; visited[a]=1; list::iterator it; for(it=frnd[a].begin();it!=frnd[a].end();++it) {dfs(*it);} }  asked 22 Jul '13, 19:21 2★wonder 361●18●37●69 accept rate: 0% 4★kunal361 6.0k●13●32●72 koi to help karo.......:( (22 Jul '13, 19:50) wonder2★

### The question has been closed for the following reason "Duplicate Question" by kunal361 22 Jul '13, 21:53

 0 http://www.codechef.com/viewsolution/2399108 check out this code just edited your code littlebuit and got AC 1.change ints to long long 2.mod should be 10^9+7 3.apply mod like this captain=(captain%m*y%m)%m answered 22 Jul '13, 21:52 31●1●1●5 accept rate: 0%

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,070

question asked: 22 Jul '13, 19:21

question was seen: 423 times

last updated: 22 Jul '13, 21:53