My code is giving WAs in few test cases, can someone help in finding the failing test cases and the bug.
Problem:INDEP Problem - CodeChef
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while(t--)
{
ll m,n,x,y,ans=0;
cin>>n>>m;
vector<int>edges[n];
map<vector<int>,int>freq;
for(int i=0;i<m;i++)
{
cin>>x>>y;
x--;
y--;
edges[x].push_back(y);
edges[y].push_back(x);
}
for(int i=0;i<n;i++)
{
sort(edges[i].begin(),edges[i].end());
}
for(int i=0;i<n;i++)
{
freq[edges[i]]++;
}
string a(n,'1');
for(auto it:freq)
{
vector<int>temp = it.first;
if(temp.size()+it.second==n )
{
ans++;
}
if(ans==1)
{
for(int i=0;i<temp.size();i++)
{
a[temp[i]]='0';
}
}
}
if(ans==0)
{
a=string(n,'0');
}
cout<<ans<<"\n";
cout<<a<<"\n";
}
}