#include <iostream>
#include <vector>
using namespace std;
void printv(const vector<int> &wyn) {
	for (auto i: wyn)
		cout << i << " ";
	cout << endl;
}
void printb(const vector<bool> &wyn) {
	for (auto i: wyn)
		cout << i << " ";
	cout << endl;
}
bool spojne(const vector<bool> &v) {
	int i = 0;
	for (i; (i < v.size()) && (!v[i]); i++);
	for (i; (i < v.size()) && (v[i]); i++);
	for (i; (i < v.size()) && (!v[i]); i++);
	return i==v.size();
}
void wykonaj(vector<bool> &v, const vector<pair<int,int>> &r) {
	for (auto roz: r) {
		if (v[roz.first-1] && !v[roz.second-1]) {
			v[roz.first-1] = false;
			v[roz.second-1] = true;
		}
	}
}
void gen(vector<bool> v, int liczba, int pos, vector<bool> &wyn, 
    const vector<pair<int,int>> &r ) {
	if (v.size() <= pos) {
		wykonaj(v,r);
		if (spojne(v))
			wyn[liczba] = !wyn[liczba];
		return;
	}
	gen(v,liczba,pos+1, wyn, r);
	v[pos] = true;
	gen(v, liczba+1, pos+1, wyn, r);
}
int main() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,m;
	vector<bool> zol;
	vector<bool> wynik;
	vector<pair<int,int>> rozkazy;
	cin >> n >> m;
	int r1, r2;
	for (int i=0; i<n; i++) {
		zol.push_back(false);
		wynik.push_back(false);
	}
	wynik.push_back(false);
    for (int i=0; i<m; i++) {
		cin >> r1 >> r2;;
		rozkazy.push_back(make_pair(r1, r2));
	}
	gen(zol,0,0,wynik, rozkazy);
	for (int i=1; i<=n; i++) 
		if (wynik[i]) 
			cout << 1 << " ";
		else
			cout << 0 << " ";
	cout << "\n";
}
        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 73 74 75 76  | #include <iostream> #include <vector> using namespace std; void printv(const vector<int> &wyn) { for (auto i: wyn) cout << i << " "; cout << endl; } void printb(const vector<bool> &wyn) { for (auto i: wyn) cout << i << " "; cout << endl; } bool spojne(const vector<bool> &v) { int i = 0; for (i; (i < v.size()) && (!v[i]); i++); for (i; (i < v.size()) && (v[i]); i++); for (i; (i < v.size()) && (!v[i]); i++); return i==v.size(); } void wykonaj(vector<bool> &v, const vector<pair<int,int>> &r) { for (auto roz: r) { if (v[roz.first-1] && !v[roz.second-1]) { v[roz.first-1] = false; v[roz.second-1] = true; } } } void gen(vector<bool> v, int liczba, int pos, vector<bool> &wyn, const vector<pair<int,int>> &r ) { if (v.size() <= pos) { wykonaj(v,r); if (spojne(v)) wyn[liczba] = !wyn[liczba]; return; } gen(v,liczba,pos+1, wyn, r); v[pos] = true; gen(v, liczba+1, pos+1, wyn, r); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; vector<bool> zol; vector<bool> wynik; vector<pair<int,int>> rozkazy; cin >> n >> m; int r1, r2; for (int i=0; i<n; i++) { zol.push_back(false); wynik.push_back(false); } wynik.push_back(false); for (int i=0; i<m; i++) { cin >> r1 >> r2;; rozkazy.push_back(make_pair(r1, r2)); } gen(zol,0,0,wynik, rozkazy); for (int i=1; i<=n; i++) if (wynik[i]) cout << 1 << " "; else cout << 0 << " "; cout << "\n"; }  | 
            
        
                    English