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
#include <cstdio>
#include <vector>

using ll = long long;

const int N = 37;
const int M = 1007;

int changes[2][M];
std::vector<ll> teams[2];
ll combinations[N];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);

    for (int i = 0; i < m; i++)
        scanf("%d%d", &changes[0][i], &changes[1][i]);

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ll s = 0;

            for (int k = i; k <= j; k++)
                s |= (ll)1 << k;

            int b = 0;

            teams[0].clear();
            teams[1].clear();
            teams[b].push_back(s);

            for (int k = m - 1; k >= 0; k--) {
                teams[1 - b].clear();
                int x = changes[0][k] - 1;
                int y = changes[1][k] - 1;

                for (ll t : teams[b]) {
                    ll wx = t & ((ll)1 << x);
                    ll wy = t & ((ll)1 << y);

                    if ((wx && wy) || (!wx && !wy)) {
                        teams[1 - b].push_back(t);
                    } else if (!wx && wy) {
                        teams[1 - b].push_back(t);
                        ll u = t | ((ll)1 << x);
                        u &= ~((ll)1 << y);
                        teams[1 - b].push_back(u);
                    }
                }

                b = 1 - b;
            }

            combinations[j - i + 1] += teams[b].size();
        }
    }

    printf("%d ", n & 1);

    for (int i = 2; i <= n; i++)
        printf("%lld ", combinations[i] & 1);

    printf("\n");

    return 0;
}