Advertisement
momo2345

Omkar and Tree

May 25th, 2023
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define suni ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
  4. int main()
  5. {
  6.     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  7.     long long  n, m, u, a,b,c;
  8.     map<long long, bool> mp;
  9.     int tc;
  10.     cin>>tc;
  11.     while(tc--)
  12.     {
  13.         mp.clear();
  14.         cin>>n>>m;
  15.         for(long long i=1; i<=m; i++)
  16.         {
  17.             cin>>a>>b>>c;
  18.             mp[b] = true;
  19.         }
  20.         for(long long i=1; i<=n; i++)
  21.         {
  22.             if(mp[i] == false)
  23.             {
  24.                 u= i;
  25.                 break;
  26.             }
  27.         }
  28.         for(long long i=1; i<=n; i++)
  29.         {
  30.             if(i != u) cout<<u<<" "<<i<<endl;
  31.         }
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement