General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
126821755 Practice:
devesh002
1106D - 17 C++17 (GCC 7-32) Wrong answer on test 30 124 ms 18540 KB 2021-08-24 11:49:12 2021-08-24 11:49:13
→ Source
#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007
typedef long long int ll;
//#define int ll
vector<ll> v;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define ff first
#define ss second
#define pb push_back
#define all(s) s.begin(), s.end()
#define tc   \
   int t;    \
   cin >> t; \
   while (t--)
#define inp                    \
   for (int i = 0; i < n; i++) \
   {                           \
      ll j;                    \
      cin >> j;                \
      vec.pb(j);               \
   }
#define INF 1e17
#define file_read(x, y)    \
   freopen(x, "r", stdin); \
   freopen(y, "w", stdout);
#define apes_together_strong   ios_base::sync_with_stdio(false);cin.tie(0);

vector<vector<ll>>adj(1e5+10);
vector<bool> visit(1e5+10,false);
priority_queue <ll,vector<ll>,greater<ll>> p;
void dfs(ll x)
{
   if(p.empty()==true) return;
ll a=p.top();
p.pop();
if(visit[a]==true) return ;
cout<<a<<" ";
visit[a]=true;
for(ll i=0;i<adj[a].size();i++)
{
   if(visit[adj[a][i]]==false){
   p.push(adj[a][i]);;}
}
for(ll i=0;i<p.size();i++)
{
   
   dfs(p.top());
}
}
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
int main()
{
   apes_together_strong
ll i,j,k,n,m;
cin>>n>>m;
for(i=0;i<m;i++)
{
cin>>j>>k;
adj[j].pb(k);
adj[k].pb(j);
}
p.push(1);dfs(1);
clearQueue(p);
for(ll i=2;i<n;i++)
{
if(visit[i]==false)
{
   p.push(i);
   dfs(p.top());clearQueue(p);
}
}
// for(i=2;i<=n;i++)
// {
//    p.push(i);
//    dfs(p.top());
//    clearQueue(p);
//    }
cout<<endl;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details