https://www.codechef.com/problems/PERCAPTA

#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
bool vis[200004]; long double dp[200004],ma; vectorv[200004],tg,tv,cur;
void dfs(int n){ vis[n]=1;
for(int x:v[n])if(!vis[x]&&dp[x]==dp[n]){cur.pb(x);dfs(x); }}

int main(){
int i,j,k,t,m,n;
cin>>t; while(t–){ ma=-1; memset(vis,0,sizeof(vis));long double a[200004],b[200004];
cin>>n>>m;for(i=0;i<=n;i++)dp[i]=-1,v[i].clear();
for(i=0;i<n;i++)cin>>a[i]; for(i=0;i<n;i++)cin>>b[i];
for(i=0;i<m;i++){cin>>j>>k; j–; k–;
v[j].pb(k); v[k].pb(j);}
for(i=0;i<n;i++)dp[i]=a[i]/b[i],ma=max(ma,dp[i]);
for(i=0;i<n;i++)if(dp[i]==ma)tv.pb(i);
for(i=0;i<tv.size();i++){ if(!vis[tv[i]]){ cur.pb(tv[i]); dfs(tv[i]);
if(cur.size()>tg.size())tg=cur;
cur.clear();}}

cout<<tg.size()<<"\n"; for(i=0;i<tg.size();i++)cout<<tg[i]+1<<" ";
cout<<"\n";

tv.clear();tg.clear(); cur.clear();
}
return 0;}

can someone help to remove tle ?