Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

hopingsteam Apr 8th, 2020 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include    <iostream>
  2. #include    <fstream>
  3. #include    <vector>
  4.  
  5. using namespace std;
  6.  
  7. ifstream fin("bac.in");
  8.  
  9. const int NLIM = 1005;
  10. vector < int > Muchii[NLIM];
  11.  
  12. int k;
  13. int Grad[NLIM];
  14. bool Vizitat[NLIM];
  15.  
  16. void DFS(int Nod)
  17. {
  18.     Vizitat[Nod] = true;
  19.     Grad[Nod] = 0;
  20.     for(int i = 0; i < Muchii[Nod].size(); i++)
  21.     {
  22.         int Vecin = Muchii[Nod][i];
  23.         Grad[Vecin]--;
  24.         if(!Vizitat[Vecin] && Grad[Vecin] < k)
  25.             DFS(Vecin);
  26.     }
  27. }
  28.  
  29. int main()
  30. {
  31.     int n, m;
  32.     fin >> n >> m >> k;
  33.     for(int i = 1; i <= m; i++)
  34.     {
  35.         int x, y;
  36.         fin >> x >> y;
  37.         Muchii[x].push_back(y);
  38.         Muchii[y].push_back(x);
  39.     }
  40.  
  41.     for(int i = 1; i <= n; i++)
  42.     {
  43.         Grad[i] = Muchii[i].size();
  44.         cout << Muchii[i].size() << " ";
  45.     }
  46.     cout << "\n";
  47.  
  48.     for(int i = 1; i <= n; i++)
  49.     {
  50.         int grad = Muchii[i].size();
  51.         if(grad < k && !Vizitat[i])
  52.             DFS(i);
  53.     }
  54.  
  55.     int k = 0;
  56.     for(int i = 1; i <= n; i++)
  57.     {
  58.         if(!Vizitat[i] && Grad[i])
  59.         {
  60.             cout << i << " ";
  61.             k++;
  62.         }
  63.     }
  64.  
  65.     if(k == 0)
  66.         cout << "NU";
  67.     return 0;
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top