SHARE
TWEET

Impreza

a guest Dec 11th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma GCC optimize("O3")
  2. #include <bits/stdc++.h>
  3.  
  4. bool matrix[3030][3030];
  5. bool erased[3030];
  6.  
  7. int32_t main()
  8. {
  9.   std::ios_base::sync_with_stdio(false);
  10.   std::cin.tie(NULL);
  11.   std::cout.tie(NULL);
  12.  
  13.   int friends_number; std::cin >> friends_number;
  14.   int pairs_number; std::cin >> pairs_number;
  15.  
  16.   for (size_t i = 0; i < pairs_number; ++i)
  17.   {
  18.     int first, second; std::cin >> first >> second;
  19.     matrix[--first][--second] = matrix[second][first] = true;
  20.   }
  21.  
  22.   for (size_t i = 0; i < friends_number; ++i)
  23.   {
  24.     for (size_t j = i + 1; j < friends_number & !erased[i]; ++j)
  25.     {
  26.       if (!matrix[i][j] && !erased[j])
  27.       {
  28.         erased[i] = erased[j] = true;
  29.       }
  30.     }
  31.   }
  32.  
  33.   int output_size = friends_number / 3;
  34.  
  35.   for (size_t i = 0; output_size && i < friends_number; ++i)
  36.   {
  37.     if (!erased[i])
  38.     {
  39.       --output_size;
  40.       std::cout  << i + 1 << ' ';
  41.     }
  42.   }
  43.   std::cout << '\n';
  44.   return 0;
  45. }
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