Please Help! Runtime Error

Please help me finding why I am getting Runtime Error in my code.
#include<bits/stdc++.h>
using namespace std;

int board[9],steps[98765435]={0},all_combos[362881]={123456789},m=1,n=-1,tempf,tempi,p[9]={100000000,10000000,1000000,100000,10000,1000,100,10,1},prime[18]={0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1};
void move(int i1,int i2){
int d=board[i2]-board[i1];
tempf=tempi+dp[i1]-dp[i2];
int tempp=tempf/10;
tempi/=10;
if(!steps[tempp]){
steps[tempp]=steps[tempi]+1;
all_combos[m++]=tempf;
}
}

int main()
{
all_combos[0]=123456789;
steps[12345678]=1;
while(++n<m){
tempi=all_combos[n];
for(int i=8;i>=0;i–){
board[i]=tempi%10;
tempi/=10;
}
if(prime[board[0]+board[1]]) move(0,1);
if(prime[board[0]+board[3]]) move(0,3);
if(prime[board[1]+board[2]]) move(1,2);
if(prime[board[1]+board[4]]) move(1,4);
if(prime[board[2]+board[5]]) move(2,5);
if(prime[board[3]+board[4]]) move(3,4);
if(prime[board[3]+board[6]]) move(3,6);
if(prime[board[4]+board[5]]) move(4,5);
if(prime[board[4]+board[7]]) move(4,7);
if(prime[board[5]+board[8]]) move(5,8);
if(prime[board[6]+board[7]]) move(6,7);
if(prime[board[7]+board[8]]) move(7,8);
}
int t;
cin>>t;
while(t–)
{
int x=0,y;
for(int i=0;i<8;i++)
{
cin>>y;
x=x*10+y;
}
cin>>y;
if(steps[x]) cout<<steps[x]-1<<"\n";
else cout<<"-1\n";
}
return 0;
}

It’s not from an ongoing contest. I’ve seen this question before.


Oh okay.

1 Like

He solved it.

4 Likes

yes finally I debugged it

1 Like