 # TABUS algorithm

Hello,I have made the TABUS problem,tested it with different test cases,and they all succeeded,but I still get a wrong answer.Apparently,this line of code makes the difference && current_time<=time_counter
(line 40).I would appreciate if you would tell me what i am doing wrong
#include <stdio.h>
#include
using namespace std;

struct bus{
int start_station;
int stop_station;
int start_time;
int stop_time;
};
vector < vector< bus *> > * station_vector;
long time_counter=1000000001;
long M,U,V,T;
int N,k;
bool ok=false;

void my_function(long current_position,int current_time,long ex_bus_index,long ex_current_position)
{
if((current_position+1)!=N)
{
for(long i=0;i< (*station_vector)[current_position].size();i++)
{

``````        if(current_position==0)
{
current_time=(*station_vector)[current_position][i]->start_time;
k=current_time;

}
else
{
k=(*station_vector)[current_position][i]->start_time-(*station_vector)[ex_current_position][ex_bus_index]->stop_time ;
if(current_time<k)
{
current_time=k;
}
}

if((*station_vector)[current_position][i]->stop_time <=T
&& current_time<=time_counter
)
{
my_function((*station_vector)[current_position][i]->stop_station-1,current_time,i,current_position);

}

}
}
else if( (*station_vector)[ex_current_position][ex_bus_index]->stop_time<=T &&current_time<time_counter)
{
time_counter=current_time;
ok=true;
}
``````

}

int main()
{
//FILE *in=fopen(“test.txt”, “r”);
scanf("%d%ld%ld",&N,&T,&M);

``````station_vector=new vector < vector<bus *> >(N);

for(long i=0;i<M;i++)
{
bus * bustruct=new bus;
scanf("%ld%ld%d%d",&(bustruct->start_station),&(bustruct->stop_station),&(bustruct->start_time),&(bustruct->stop_time));
if(bustruct->stop_time<=T)
{
(*station_vector)[bustruct->start_station-1].push_back(bustruct);

}

}
``````

my_function(0,0,0,0);
delete station_vector;
station_vector=0;
if(ok==true)
{
printf("%ld\n",time_counter);

``````}
else
{
printf("%d\n",-1);
}

return 0;
``````

}

Hello alchemyofdeath !

I will appreciate you if you solve my problem to the same question … here is the link , i too have posted on forum with algorithm :

//