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
#include <bits/stdc++.h>
using namespace std;
constexpr int M = 1005;
pair<long long, long long> ruchy[M];
long long wynik[M];
long long tab[M];

int main() {
    long long n, m;
    cin>>n>>m;
    for(int i=1; i<=m; i++) cin>>ruchy[i].first>>ruchy[i].second;
    for(long long i=1; i<(1<<n); i++){
    	long long ile1 = 0;
    	long long ilee = 0;
    	for(long long j=0; j<n; j++){
    		if(i & (1<<j)) ile1++, tab[j+1] = 1;
    		else tab[j+1] = 0;
    	}
    	for(long long j=1; j<=m; j++) if(tab[ruchy[j].first]==1 && tab[ruchy[j].second]==0) swap(tab[ruchy[j].first], tab[ruchy[j].second]);
    	for(long long j=1; j<=n; j++) if(tab[j] != tab[j+1]) ilee++;
    	if(ilee <= 2) wynik[ile1]++;
    }
    for(long long i=1; i<=n; i++) cout<<wynik[i]%2<<" ";
    cout<<endl;
    return 0;
}