#include "garden.h"
#include "gardenlib.h"
#include <iostream>
using namespace std;
long long int ans,n,m,p,map[1005][1005],tag[10005],ta;
int find(int x,int pe)
{
//cout<<x<<" "<<pe<<endl;
if(pe==ta)
{
if(x==p)ans++;
return 0;
}
int tmp=0,now=-1,h=0;
for(int i=0;i<n;i++)
{
if(map[x][i]!=-1)
{
if(now==-1)
{
if(tag[map[x][i]]==1)h=1;
tmp=map[x][i];
now=i;
}
else
if(h==1)
{
if(tag[map[x][i]]==0)
{
tmp=map[x][i];
now=i;
h=0;
}
else if(map[x][i]<tmp)
{
tmp=map[x][i];
now=i;
}
}
else if(tag[map[x][i]]==0 && map[x][i]<tmp)
{
//cout<<"ok"<<endl;
tmp=map[x][i];
now=i;
}
//cout<<h<<" "<<tmp<<" "<<now<<" "<<i<<" "<<map[x][i]<<endl;
}
}
tag[tmp]=1;
find(now,pe+1);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
n=N,m=M,p=P,ta=G[0];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)map[i][j]=-1;
}
for(int i=0;i<m;i++)
{
map[R[i][0]][R[i][1]]=i;
map[R[i][1]][R[i][0]]=i;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)tag[j]=0;
//cout<<i<<endl;
find(i,0);
}
answer(ans);
}
Compilation message
garden.cpp: In function 'int find(int, int)':
garden.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |