1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <tuple>
#include <vector>

namespace {
	using std::ios_base, std::cin, std::cout;
	using std::vector;

	using order_t = std::pair<size_t, size_t>;
	using v_order_t = vector<order_t>;
	using v_soldiers_t = vector<bool>;
	using vv_soldiers_t = vector<v_soldiers_t>;

	void revert_orders(v_order_t const & orders, vv_soldiers_t & v_soldiers) {
		bool end;
		for (auto it = orders.rbegin(); it != orders.rend(); ++it) {
			end = false;
			for (auto it_s = v_soldiers.begin(); it_s != v_soldiers.end(); !end ? ++it_s : it_s) {
				end = false;
				if ((*it_s)[it->first - 1] == true && (*it_s)[it->second - 1] == false) {
					it_s = v_soldiers.erase(it_s);
					end = true;
				}
			}
			auto size = v_soldiers.size();
			for (size_t idx = 0; idx < size; ++idx) {
				if (v_soldiers[idx][it->first - 1] == false && v_soldiers[idx][it->second - 1] == true) {
					v_soldiers.push_back(v_soldiers[idx]);
					v_soldiers[idx][it->first - 1] = true;
					v_soldiers[idx][it->second - 1] = false;
				}
			}
		}
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// Wczytanie danych
	size_t n, m;
	cin >> n;
	cin >> m;
	size_t ai, bi;
	v_order_t orders;
	for (size_t k = 0; k < m; ++k) {
		cin >> ai;
		cin >> bi;
		orders.push_back({ai, bi});
	}

	// Obliczanie wyników
	vector<size_t> cnts;
	for (size_t k = 0; k < n; ++k)
		cnts.push_back(n - k);
	for (size_t k = 2; k < n; ++k) {
		cnts[k - 1] = 0;
		for (size_t i = 0; i <= n - k; ++i) {
			v_soldiers_t soldiers(n, false);
			for (size_t j = i; j < k + i; ++j)
				soldiers[j] = true;
			vv_soldiers_t v_soldiers;
			v_soldiers.push_back(soldiers);
			revert_orders(orders, v_soldiers);
			cnts[k - 1] += v_soldiers.size();
		}
	}
	for (auto const & c: cnts)
		cout << c % 2 << ' ';
	cout << '\n';
}