this is my code any help will be appreciated
#include<bits/stdc++.h>
using namespace std;
const int maxSize = 1e5+1;
vectoradj[maxSize];
int par[maxSize];
int dp[maxSize];
int n;
int solve(int node)
{
if(node == n)
{
return 1;
}
else if(dp[node]!=-1)
{
return dp[node];
}
else
{
int ans = INT_MIN;
for(auto nde:adj[node])
{
int temp = solve(nde)+1;
if(ans<=temp)
{
ans = temp;
par[nde] = node;
}
}
return dp[node] = ans;
}
}
int main()
{
memset(dp,-1,sizeof dp);
int m;
cin>>n>>m;
int i;
for(i=0;i<m;i++)
{
int first,second;
cin>>first>>second;
adj[first].push_back(second);
}
int dist = solve(1);
if(dist <= 0 || dist == INT_MIN)
{
cout<<“IMPOSSIBLE”<<endl;
}
else
{ cout<<dist<<endl;
int temp = n;
par[1] = -1;
vectorans;
// for(i=1;i<=n;i++)
// {
// cout<<par[i]<<" “;
// }
while(temp!=-1)
{
ans.push_back(temp);
temp = par[temp];
}
reverse(ans.begin(),ans.end());
for(auto nde:ans)
{
cout<<nde<<” ";
}
}
}