Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <map>
- #include <utility>
- #include <algorithm>
- #include <cmath>
- #include <string>
- #include <fstream>
- using namespace std;
- typedef long long int ll;
- #define forn(i, n) for(int (i) = 0; (i) < (n); (i)++)
- #define fora(i, arr) for(auto (i) = (arr).begin(); (i) != (arr).end(); (i)++)
- #define ford(i, n, j, m) for(int (i) = 0; (i) < (n); (i)++) for(int (j) = 0; (j) < (m); (j)++)
- #define fors(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
- #define pb push_back
- #define all(a) (a).begin(), (a).end()
- #define sortf(a) sort(all(a))
- #define lin(arr, t, n) int (n); cin >> (n); vector<t> (arr)((n)); forn(i, n) cin >> (arr)[i]
- #define lini(arr) forn(i, (arr).size()) cin >> (arr)[i]
- #ifdef _MSC_VER
- #define DEBUG(s) cout << (s);
- #define DEBUGE(s) cout << (s) << endl;
- #define DEBEND cout << endl;
- #else
- #define DEBUG(s)
- #define DEBUGE(s)
- #define DEBEND
- #endif
- typedef vector<int> vi;
- typedef vector<ll> vll;
- typedef pair<int, int> pi;
- typedef pair<ll, ll> pll;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- #ifndef _MSC_VER
- ifstream cin("input.txt");
- ofstream cout("output.txt");
- #endif
- int n, k;
- cin >> n >> k;
- vector<set<int>> graph(n);
- forn(i, n) {
- forn(j, n) {
- int a;
- cin >> a;
- if (a) {
- graph[i].insert(j);
- }
- }
- }
- vector<bool> good(n);
- vector<bool> used(n);
- int curg = n;
- forn(i, n) {
- forn(i, n) {
- good[i] = 0;
- if ((int)graph[i].size() >= k && curg - (int)graph[i].size() - 1 >= k) {
- good[i] = 1;
- }
- }
- forn(i, n) {
- if (!good[i] && !used[i]) {
- for (auto j : graph[i]) {
- graph[j].erase(i);
- }
- graph[i].clear();
- used[i] = 1;
- curg--;
- }
- }
- }
- int c = 0;
- forn(i, n) {
- c += good[i];
- }
- cout << c << endl;
- forn(i, n) {
- if (good[i]) cout << i + 1 << " ";
- }
- cout << endl;
- #ifdef _MSC_VER
- std::system("pause");
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement