Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <map>
  5. #include <utility>
  6. #include <algorithm>
  7. #include <cmath>
  8. #include <string>
  9. #include <fstream>
  10. using namespace std;
  11. typedef long long int ll;
  12. #define forn(i, n) for(int (i) = 0; (i) < (n); (i)++)
  13. #define fora(i, arr) for(auto (i) = (arr).begin(); (i) != (arr).end(); (i)++)
  14. #define ford(i, n, j, m) for(int (i) = 0; (i) < (n); (i)++) for(int (j) = 0; (j) < (m); (j)++)
  15. #define fors(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
  16. #define pb push_back
  17. #define all(a) (a).begin(), (a).end()
  18. #define sortf(a) sort(all(a))
  19. #define lin(arr, t, n) int (n); cin >> (n); vector<t> (arr)((n)); forn(i, n) cin >> (arr)[i]
  20. #define lini(arr) forn(i, (arr).size()) cin >> (arr)[i]
  21.  
  22. #ifdef _MSC_VER
  23. #define DEBUG(s) cout << (s);
  24. #define DEBUGE(s) cout << (s) << endl;
  25. #define DEBEND cout << endl;
  26. #else
  27. #define DEBUG(s)
  28. #define DEBUGE(s)
  29. #define DEBEND
  30. #endif
  31.  
  32. typedef vector<int> vi;
  33. typedef vector<ll> vll;
  34. typedef pair<int, int> pi;
  35. typedef pair<ll, ll> pll;
  36.  
  37. int main() {
  38.     ios_base::sync_with_stdio(false);
  39.     cin.tie(0);
  40.     cout.tie(0);
  41. #ifndef _MSC_VER
  42.     ifstream cin("input.txt");
  43.     ofstream cout("output.txt");
  44. #endif
  45.     int n, k;
  46.     cin >> n >> k;
  47.     vector<set<int>> graph(n);
  48.     forn(i, n) {
  49.         forn(j, n) {
  50.             int a;
  51.             cin >> a;
  52.             if (a) {
  53.                 graph[i].insert(j);
  54.             }
  55.         }
  56.     }
  57.     vector<bool> good(n);
  58.     vector<bool> used(n);
  59.     int curg = n;
  60.     forn(i, n) {
  61.         forn(i, n) {
  62.             good[i] = 0;
  63.             if ((int)graph[i].size() >= k && curg - (int)graph[i].size() - 1 >= k) {
  64.                 good[i] = 1;
  65.             }
  66.         }
  67.         forn(i, n) {
  68.             if (!good[i] && !used[i]) {
  69.                 for (auto j : graph[i]) {
  70.                     graph[j].erase(i);
  71.                 }
  72.                 graph[i].clear();
  73.                 used[i] = 1;
  74.                 curg--;
  75.             }
  76.         }
  77.     }
  78.     int c = 0;
  79.     forn(i, n) {
  80.         c += good[i];
  81.     }
  82.     cout << c << endl;
  83.     forn(i, n) {
  84.         if (good[i]) cout << i + 1 << " ";
  85.     }
  86.     cout << endl;
  87. #ifdef _MSC_VER
  88.     std::system("pause");
  89. #endif
  90.     return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement