int g[maxn][maxn]; voidGauss(){ for (int i = 1; i <= n; ++i) { int p = -1; for (int j = i; j <= n; ++j) if (g[j][i]) p = j; if (p == -1) continue; swap(g[p], g[i]); for (int j = 1; j <= n; ++j) { if (i == j || !g[j][i]) continue; for (int k = i; k <= n + 1; ++k) g[j][k] ^= g[i][k]; } } for (int i = 1; i <= n; ++i) { int s = 0; for (int j = i; j <= n; ++j) s |= g[i][j]; if (!s && g[i][n + 1]) return (void) (cout << "N\n"); } cout << "Y\n"; }
cin >> n >> m; for (int i = 1; i <= m; ++i) { int x, y; cin >> x >> y; ++du[x]; ++du[y]; G[x].push_back(y); G[y].push_back(x); } for (int i = 1; i <= n; ++i) if (du[i] % 2 == 0) { for (auto u : G[i]) g[i][u] = 1; g[i][n + 1] = 1; } else { for (auto u : G[i]) g[i][u] = 1; g[i][i] = 1; g[i][n + 1] = 0; } Gauss(); return0; }