text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; vector<bool> row1; vector<bool> col1; vector<bool> row2; vector<bool> col2; int main() { int n, m; bool b; cin >> n >> m; row1.resize(n); row2.resize(n); col1.resize(m); col2.resize(m); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> b; if (b) { row1[i] = !row1[i]; col1[j] = !col1[j]; } } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> b; if (b) { row2[i] = !row2[i]; col2[j] = !col2[j]; } } } for (int i = 0; i < n; ++i) { if (row1[i] != row2[i]) { cout << "No" << endl; return 0; } } for (int j = 0; j < m; ++j) { if (col1[j] != col2[j]) { cout << "No" << endl; return 0; } } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[n][m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int x; cin >> x; if (a[i][j] == x) a[i][j] = 0; else a[i][j] = 1; } } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < m; j++) { if (a[i][j]) { int k = j + 1; while (k < m and a[i][k] != 1) k++; if (k == m) return !(cout << "No" << endl); a[i][j] ^= 1; a[i][k] ^= 1; a[i + 1][j] ^= 1; a[i + 1][k] ^= 1; } } } for (int i = 0; i < m; i++) if (a[n - 1][i]) return !(cout << "No" << endl); cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int mapp1[505][505], mapp2[505][505]; int n, m; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> mapp1[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> mapp2[i][j]; if (mapp1[i][j] == mapp2[i][j]) { mapp1[i][j] = 1; } else { mapp1[i][j] = 0; } } } bool ok = true; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (mapp1[i][j] == 0) { int l = -1; for (int ii = i + 1; ii < n; ii++) { if (mapp1[ii][j] == 0) { l = ii; } } int r = -1; for (int jj = j + 1; jj < m; jj++) { if (mapp1[i][jj] == 0) { r = jj; } } if (l == -1 || r == -1) { ok = false; break; } else { mapp1[i][j] = (mapp1[i][j] + 1) % 2; mapp1[l][j] = (mapp1[l][j] + 1) % 2; mapp1[i][r] = (mapp1[i][r] + 1) % 2; mapp1[l][r] = (mapp1[l][r] + 1) % 2; } } } } if (ok) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
#include <bits/stdc++.h> using namespace std; const int maxn = 4e5 + 5; const int MOD = 1e9 + 7; int a[510][510], b[510][510]; int c[510][510]; int d1[510], d2[510]; int main() { int n, m; while (~scanf("%d %d", &n, &m)) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &a[i][j]); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &b[i][j]); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { c[i][j] = a[i][j] ^ b[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { d1[i] += c[i][j]; } } for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { d2[i] += c[j][i]; } } bool flag = 0; for (int i = 1; i <= n; i++) { if (d1[i] % 2 == 1) { flag = 1; } } for (int i = 1; i <= m; i++) { if (d2[i] % 2 == 1) { flag = 1; } } if (flag == 1) { puts("No"); } else { puts("Yes"); } } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 509; int a[MAXN][MAXN], b[MAXN][MAXN]; bool err; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &a[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &b[i][j]); } } for (int i = 0; i < n && !err; i++) { int cnt = 0; for (int j = 0; j < m; j++) { cnt += a[i][j] ^ b[i][j]; } if (cnt & 1) err = true; } for (int i = 0; i < m && !err; i++) { int cnt = 0; for (int j = 0; j < n; j++) { cnt += a[j][i] ^ b[j][i]; } if (cnt & 1) err = true; } if (err) printf("No"); else printf("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long b, long long mod = (long long)(1e9 + 7)) { if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int DEBUG = 1; const int mxn = 500; int n, m; int a[mxn][mxn], b[mxn][mxn]; void solve() { for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> b[i][j]; for (int i = 0; i < n; i++) { int bit = 0; for (int j = 0; j < m; j++) bit ^= a[i][j], bit ^= b[i][j]; if (bit) { cout << "No" << endl; return; } } for (int j = 0; j < m; j++) { int bit = 0; for (int i = 0; i < n; i++) bit ^= a[i][j], bit ^= b[i][j]; if (bit) { cout << "No" << endl; return; } } cout << "Yes" << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); while (cin >> n >> m) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; int a[n][m], b[n][m]; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> a[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> b[i][j]; } } int r[n], c[m]; memset(r, 0, sizeof r); memset(c, 0, sizeof c); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (a[i][j] != b[i][j]) ++r[i], ++c[j]; } } bool ok = true; for (int i = 0; i < n; ++i) ok &= (r[i] % 2 == 0); for (int j = 0; j < m; ++j) ok &= (c[j] % 2 == 0); cout << (ok ? "Yes" : "No") << '\n'; }
#include <bits/stdc++.h> using namespace std; int ok(vector<int>& in, int n, int h) { int cant = 0; sort(in.begin(), in.begin() + n, greater<int>()); for (int i = 0; i < n; i++) { if (i % 2 == 1) { h -= max(in[i], in[i - 1]); if (h < 0) { break; } else { cant++; } } else { if (h - in[i] < 0) { break; } else { cant++; } } } return cant; } int main() { int n, m; cin >> n >> m; vector<vector<int> > mat(n, vector<int>(m, 0)); vector<vector<int> > goal(n, vector<int>(m, 0)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; j++) { cin >> mat[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; j++) { cin >> goal[i][j]; } } bool res = true; for (int i = 0; i < n; ++i) { int count = 0; for (int j = 0; j < m; j++) { if (mat[i][j] != goal[i][j]) { count++; } } if (count % 2 == 1) { res = false; } } for (int i = 0; i < m; ++i) { int count = 0; for (int j = 0; j < n; j++) { if (mat[j][i] != goal[j][i]) { count++; } } if (count % 2 == 1) { res = false; } } if (res) cout << "Yes\n"; else cout << "No\n"; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m; long long sum = 0; long long a[500][500]; long long b[500][500]; long long v[500]; long long h[500]; int main() { cin >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> a[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> b[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (a[i][j] != b[i][j]) { v[j]++; h[i]++; } } } bool yes = true; for (int j = 0; j < m; ++j) { if (v[j] % 2 != 0) { yes = false; break; } } for (int j = 0; j < n; ++j) { if (h[j] % 2 != 0) { yes = false; break; } } if (yes) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return x * f; } const int MAXN = 510; int N, M, a[MAXN + 1][MAXN + 1], b[MAXN + 1][MAXN + 1]; int main() { N = read(), M = read(); for (int i = 1; i <= N; i++) for (int j = 1; j <= M; j++) a[i][j] = read(); for (int i = 1; i <= N; i++) for (int j = 1; j <= M; j++) b[i][j] = read(); for (int i = 1; i <= N; i++) for (int j = 1; j <= M; j++) if (a[i][j] != b[i][j]) { if (i == N || j == M) { printf("No\n"); return 0; } a[i][j] ^= 1, a[i][j + 1] ^= 1, a[i + 1][j] ^= 1, a[i + 1][j + 1] ^= 1; } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; using vll = vector<ll>; using vii = vector<ii>; const ll MOD = 998244353; const int INF = 1e9 + 9; const int MAXN = 1000; int n, m, k, a[MAXN][MAXN], b[MAXN][MAXN], good, bad; bool feasible = true; char s[MAXN], t[MAXN]; void met() { return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> b[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[i][j] == 1) good++; if (b[i][j] == 1) bad++; } if ((good - bad) % 2) feasible = false; } for (int j = 0; j < m; j++) { for (int i = 0; i < n; i++) { if (a[i][j] == 1) good++; if (b[i][j] == 1) bad++; } if ((good - bad) % 2) feasible = false; } if (feasible) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d%d", &n, &m); int a[n][m]; int b[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &a[i][j]); } } int countT = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &b[i][j]); if (a[i][j] != b[i][j]) { countT++; } } } string ans = "No"; bool flag = false; if (true || countT % 4 == 0) { for (int i = 0; i < n; i++) { int count = 0; for (int j = 0; j < m; j++) { if (a[i][j] != b[i][j]) { count++; } } if (count % 2 == 1) { flag = true; break; } } for (int i = 0; i < m && !flag; i++) { int count = 0; for (int j = 0; j < n; j++) { if (a[j][i] != b[j][i]) { count++; } } if (count % 2 == 1) { flag = true; break; } } if (!flag) { ans = "Yes"; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int N = 505; int a[N][N], b[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> b[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[i][j] != b[i][j]) { if (i == n || j == m) return cout << "No\n", 0; a[i][j] ^= 1; a[i + 1][j] ^= 1; a[i][j + 1] ^= 1; a[i + 1][j + 1] ^= 1; } } } cout << "Yes\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using vector_t = vector<int>; class binary_matrix : vector<vector_t> { int even_rows() const { int n = size(), m = front().size(); for (int i = 0; i < n; ++i) { int s = 0; for (int j = 0; j < m; ++j) s += at(i).at(j); if (s & 1) return 0; } return 1; } int even_columns() const { int n = size(), m = front().size(); for (int j = 0; j < m; ++j) { int s = 0; for (int i = 0; i < n; ++i) s += at(i).at(j); if (s & 1) return 0; } return 1; } public: binary_matrix(int n, int m) { resize(n); for (auto& row : *this) { row.resize(m); for (auto& x : row) cin >> x; } } binary_matrix(const binary_matrix& a, const binary_matrix& b) { int n = a.size(), m = a.front().size(); resize(n); for (int i = 0; i < n; ++i) { at(i).resize(m, 0); for (int j = 0; j < m; ++j) if (a[i][j] != b[i][j]) at(i).at(j) = 1; } } int valid() const { return even_rows() and even_columns(); } }; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int n, m; cin >> n >> m; binary_matrix a(n, m), b(n, m); const string ans[] = {"No", "Yes"}; cout << ans[binary_matrix(a, b).valid()]; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[n][m]; int b[n][m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { cin >> b[i][j]; a[i][j] ^= b[i][j]; } for (int i = 0; i < n; i++) { int p = 0; for (int j = 0; j < m; j++) { p ^= a[i][j]; } if (p != 0) { cout << "No\n"; return 0; } } for (int i = 0; i < m; i++) { int p = 0; for (int j = 0; j < n; j++) { p ^= a[j][i]; } if (p != 0) { cout << "No\n"; return 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFLL = 1e18; const int MOD = 1e9 + 7; const int MAXN = 500 + 5; int A[MAXN][MAXN]; int B[MAXN][MAXN]; int n, m; int main() { scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf("%d", &A[i][j]); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf("%d", &B[i][j]); for (int i = 0; i < n - 1; i++) for (int j = 0; j < m - 1; j++) { if (A[i][j]) { A[i][j] ^= 1; A[i + 1][j + 1] ^= 1; A[i][j + 1] ^= 1; A[i + 1][j] ^= 1; } if (B[i][j]) { B[i][j] ^= 1; B[i + 1][j + 1] ^= 1; B[i][j + 1] ^= 1; B[i + 1][j] ^= 1; } } for (int i = 0; i < n; i++) { if (A[i][m - 1] != B[i][m - 1]) { printf("No\n"); return 0; } } for (int i = 0; i < m; i++) { if (A[n - 1][i] != B[n - 1][i]) { printf("No\n"); return 0; } } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 500 + 5; int A[maxn][maxn], B[maxn][maxn]; void change(int i, int j) { A[i][j] ^= 1; A[i + 1][j] ^= 1; A[i][j + 1] ^= 1; A[i + 1][j + 1] ^= 1; } int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &A[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &B[i][j]); for (int i = 1; i < n; i++) { for (int j = 1; j < m; j++) if (A[i][j] != B[i][j]) change(i, j); } bool ok = true; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) ok &= A[i][j] == B[i][j]; if (ok) puts("Yes"); else puts("No"); return 0; }
#include <bits/stdc++.h> const char dl = '\n'; const long double eps = 0.00000001; const long long MOD = 1e9 + 7; const long long mod = 998244353; const double PI = 3.141592653589793238463; const long double pi = 4 * atan(1.0); using namespace std; void debug() { cout << endl; } template <typename H, typename... T> void debug(H p, T... t) { std::cout << p << " "; debug(t...); } string second, t; long long ans; int n, m, k, q; int cnta[3], cntb[3]; vector<int> row[600], col[600]; int a[600][600], b[600][600], c[600][600]; int main() { fflush(stdin); cout << fixed, cout.precision(18); ios_base::sync_with_stdio(false); cin.tie(NULL); int i, j; cin >> n >> m; for (i = 0; i < n; ++i) for (j = 0; j < m; ++j) cin >> a[i][j], cnta[a[i][j]]++; for (i = 0; i < n; ++i) for (j = 0; j < m; ++j) cin >> b[i][j], cnta[b[i][j]]++; for (i = 0; i < n; ++i) for (j = 0; j < m; ++j) if (a[i][j] != b[i][j]) col[j].push_back(i), row[i].push_back(j), c[i][j] = 1; for (i = 0; i < m; ++i) { int sz = (int)col[i].size(); if (sz % 2 != 0) return cout << "No", 0; } for (i = 0; i < n; ++i) { int sz = (int)row[i].size(); if (sz % 2 != 0) return cout << "No", 0; } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[n][m], b[n][m]; bool flag = true; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> b[i][j]; } } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < m - 1; j++) { if (j != m - 1 && i != n - 1) { if (a[i][j] != b[i][j]) { if (a[i][j] == 1) { a[i][j] = 0; } else { a[i][j] = 1; } if (a[i + 1][j] == 1) { a[i + 1][j] = 0; } else { a[i + 1][j] = 1; } if (a[i][j + 1] == 1) { a[i][j + 1] = 0; } else { a[i][j + 1] = 1; } if (a[i + 1][j + 1] == 1) { a[i + 1][j + 1] = 0; } else { a[i + 1][j + 1] = 1; } } } } } for (int i = 0; i < n; i++) { if (a[i][m - 1] != b[i][m - 1]) { flag = false; } } for (int i = 0; i < m; i++) { if (a[n - 1][i] != b[n - 1][i]) { flag = false; } } if (flag == true) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int a[509][509], b[509][509]; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> b[i][j]; } } int flag = 0; for (int i = 1; i <= n; i++) { int cnt = 0; for (int j = 1; j <= m; j++) { if (a[i][j] != b[i][j]) cnt++; } if (cnt % 2) flag = 1; } for (int i = 1; i <= m; i++) { int cnt = 0; for (int j = 1; j <= n; j++) { if (a[j][i] != b[j][i]) cnt++; } if (cnt % 2) flag = 1; } if (flag) cout << "No" << endl; else cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int A[510][510], B[510][510], M[510][510]; int main() { int n, m; while (scanf("%d%d", &n, &m) > 0) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &A[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &B[i][j]); M[i][j] = A[i][j] ^ B[i][j]; } } bool flag = true; for (int i = 0; i < n and flag; i++) { int x = 0; for (int j = 0; j < m; j++) { x ^= M[i][j]; } if (x) flag = false; } for (int j = 0; j < m and flag; j++) { int x = 0; for (int i = 0; i < n; i++) { x ^= M[i][j]; } if (x) flag = false; } printf("%s\n", flag ? "Yes" : "No"); } }
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a == 0) return b; else return gcd(b % a, a); } long long int power(long long int a, long long int b, long long int m) { long long int ans = 1; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, m; cin >> n >> m; long long int a[505][505], b[505][505]; long long int row[505] = {0}, col[505] = {0}; long long int c = 0; for (long long int i = 1; i < n + 1; i++) for (long long int j = 1; j < m + 1; j++) cin >> a[i][j]; for (long long int i = 1; i < n + 1; i++) for (long long int j = 1; j < m + 1; j++) cin >> b[i][j]; for (long long int i = 1; i < n + 1; i++) { for (long long int j = 1; j < m + 1; j++) { if (a[i][j] != b[i][j]) { c++; row[i]++; col[j]++; } } } if (c % 2) { cout << "No" << endl; return 0; } for (long long int i = 1; i < n + 1; i++) { if (row[i] % 2) { cout << "No" << endl; return 0; } } for (long long int i = 1; i < m + 1; i++) { if (col[i] % 2) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 505; int a[N][N], b[N][N]; int row[N], col[N]; int rrow[N], ccol[N]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", a[i] + j); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", b[i] + j); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[i][j] ^ b[i][j]) { row[i]++; col[j]++; } } } for (int i = 0; i < n; i++) { if (row[i] & 1) { puts("No"); return 0; } } for (int i = 0; i < m; i++) { if (col[i] & 1) { puts("No"); return 0; } } puts("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; bool a[510][510], b[510][510], t[510][510]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } memset(t, 0, sizeof(t)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> b[i][j]; } } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < m - 1; j++) { if (a[i][j] != b[i][j]) { a[i][j] ^= 1; a[i + 1][j + 1] ^= 1; a[i + 1][j] ^= 1; a[i][j + 1] ^= 1; } } } int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[i][j] != b[i][j]) { cout << "No" << endl; return 0; } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 500 + 5; int a[N][N], b[N][N], row[N], col[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> a[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> b[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[i][j] != b[i][j]) { row[i]++; col[j]++; } } } int flag = 0; for (int i = 0; i < n; i++) { if (row[i] & 1) flag = 1; } for (int i = 0; i < m; i++) { if (col[i] & 1) flag = 1; } if (flag) cout << "No" << endl; else cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int A[510][510], B[510][510]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> A[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> B[i][j]; } } for (int i = 0; i < n; i++) { int ct = 0; for (int j = 0; j < m; j++) { if (A[i][j] != B[i][j]) ct++; } if (ct % 2) { cout << "NO\n"; return 0; } } for (int j = 0; j < m; j++) { int ct = 0; for (int i = 0; i < n; i++) { if (A[i][j] != B[i][j]) ct++; } if (ct % 2) { cout << "NO\n"; return 0; } } cout << "YES\n"; }
#include <bits/stdc++.h> const double PI = acos(-1.0); using namespace std; void fast_in_out() { std::ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); } void pause() {} int dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0}; int dy[] = {-1, 1, 0, 0, -1, -1, 1, 1, 0}; const int N = 3e5 + 20; const long long mod = 1e9 + 7; const long double eps = 1e-6; int arr1[505][505]; int arr2[505][505]; int main() { fast_in_out(); int n, m; int cnt1 = 0, cnt2 = 0; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> arr1[i][j]; } bool ok = 1; for (int i = 0; i < n; i++) { int x = 0, y = 0; for (int j = 0; j < m; j++) cin >> arr2[i][j], x ^= arr1[i][j], y ^= arr2[i][j]; if (x != y) ok = 0; } int sum1 = 0, sum2 = 0; for (int i = 0; i < m; i++) { int x = 0, y = 0; for (int j = 0; j < n; j++) x += arr1[j][i], y += arr2[j][i]; sum1 += x; sum2 += y; if ((x & 1) != (y & 1)) ok = 0; } if (n < 2 || m < 2) { bool f = 1; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (arr1[i][j] != arr2[i][j]) f = 0; if (f) cout << "Yes\n"; else cout << "No\n"; } else { if (ok && ((cnt1 & 1) == (cnt2 & 1))) { cout << "Yes\n"; } else cout << "No\n"; } pause(); return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("sse4") using namespace std; const long long int MAX = -1000000000000000000; const long long int MIN = 1000000000000000000; const long long int inf = 1000000000; const long long int KOK = 100000; const long long int LOG = 30; const long long int li = 100005; const long long int mod = 1000000007; long long int n, m, cev, b[1005][1005], a[1005][1005], k, cev1; string s; vector<long long int> v; inline long long int solve() { scanf("%lld %lld", &n, &m); for (long long int i = 1; i <= n; i++) { for (long long int j = 1; j <= m; j++) scanf("%lld", &a[i][j]); } for (long long int i = 1; i <= n; i++) { for (long long int j = 1; j <= m; j++) scanf("%lld", &b[i][j]); } for (long long int i = 1; i <= n; i++) { cev1 = 0; cev = 0; for (long long int j = 1; j <= m; j++) cev += a[i][j]; for (long long int j = 1; j <= m; j++) cev1 += b[i][j]; if (cev % 2 != cev1 % 2) { printf("No\n"); return 0; } } for (long long int j = 1; j <= m; j++) { cev1 = 0; cev = 0; for (long long int i = 1; i <= n; i++) cev += a[i][j]; for (long long int i = 1; i <= n; i++) cev1 += b[i][j]; if (cev % 2 != cev1 % 2) { printf("No\n"); return 0; } } printf("Yes\n"); return 0; } int main(void) { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int a[505][505], b[505][505]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &b[i][j]); for (int i = 1; i < n; i++) for (int j = 1; j < m; j++) { if (a[i][j] != b[i][j]) a[i][j] ^= 1, a[i + 1][j] ^= 1, a[i][j + 1] ^= 1, a[i + 1][j + 1] ^= 1; } bool mark = true; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) if (a[i][j] != b[i][j]) { mark = false; break; } if (!mark) break; } puts(mark ? "Yes" : "No"); return 0; }
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a == 0) return b; else return gcd(b % a, a); } long long int power(long long int a, long long int b, long long int m) { long long int ans = 1; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, m; cin >> n >> m; long long int a[505][505], b[505][505]; long long int row[505] = {0}, col[505] = {0}; long long int c = 0; for (long long int i = 1; i < n + 1; i++) for (long long int j = 1; j < m + 1; j++) cin >> a[i][j]; for (long long int i = 1; i < n + 1; i++) for (long long int j = 1; j < m + 1; j++) cin >> b[i][j]; for (long long int i = 1; i < n + 1; i++) { for (long long int j = 1; j < m + 1; j++) { if (a[i][j] != b[i][j]) { c++; row[i]++; col[j]++; } } } if (c % 2) { cout << "No" << endl; return 0; } for (long long int i = 1; i < n + 1; i++) { if (row[i] % 2) { cout << "No" << endl; return 0; } } for (long long int i = 1; i < m + 1; i++) { if (col[i] % 2) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <bits/stdc++.h> using namespace std; int n, m; int a[505][505]; int main(int argc, char* argv[]) { scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", a[i] + j); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { int x; scanf("%d", &x); a[i][j] ^= x; } for (int i = 1; i <= n; i++) { int cnt = 0; for (int j = 1; j <= m; j++) { cnt += a[i][j]; } if (cnt & 1) { printf("No"); return 0; } } for (int j = 1; j <= m; j++) { int cnt = 0; for (int i = 1; i <= n; i++) cnt += a[i][j]; if (cnt & 1) { printf("No"); return 0; } } printf("Yes"); }
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7, P2 = 998244353, INF = 0x3f3f3f3f; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long qpow(long long a, long long n) { long long r = 1 % P; for (a %= P; n; a = a * a % P, n >>= 1) if (n & 1) r = r * a % P; return r; } long long inv(long long first) { return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P; } inline int rd() { int first = 0; char p = getchar(); while (p < '0' || p > '9') p = getchar(); while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar(); return first; } const int N = 555; int n, m, a[N][N], b[N][N]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) scanf("%d", a[i] + j); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) a[i][j] ^= rd(); for (int i = 1; i <= n; ++i) { int sum = 0; for (int j = 1; j <= m; ++j) if (a[i][j]) { a[i + 1][j] ^= 1, ++sum; } if (sum & 1) return puts("No"), 0; } int sum = 0; for (int i = 1; i <= m; ++i) sum += a[n + 1][i]; puts(sum ? "No" : "Yes"); }
#include <bits/stdc++.h> using namespace std; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } vector<string> vec_splitter(string s) { s += ','; vector<string> res; while (!s.empty()) { res.push_back(s.substr(0, s.find(','))); s = s.substr(s.find(',') + 1); } return res; } void debug_out(vector<string> __attribute__((unused)) args, __attribute__((unused)) int idx, __attribute__((unused)) int LINE_NUM) { cerr << '\n'; } template <typename Head, typename... Tail> void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) { if (idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") "; stringstream ss; ss << H; cerr << args[idx] << " = " << ss.str(); debug_out(args, idx + 1, LINE_NUM, T...); } const long long M = 1000000007; void solve() { long long n, i, j, x, m, y; cin >> n >> m; vector<vector<char>> a(n, vector<char>(m, '0')), b(n, vector<char>(m, '0')); for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cin >> x; if (x == 1) a[i][j] = '1'; } } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cin >> x; if (x == 1) b[i][j] = '1'; } } long long sum = 0; for (i = 0; i < n; i++) { sum = 0; for (j = 0; j < m; j++) { sum += (a[i][j] != b[i][j]); } if (sum % 2 != 0) { cout << "No" << '\n'; return; } } for (j = 0; j < m; j++) { sum = 0; for (i = 0; i < n; i++) { sum += (a[i][j] != b[i][j]); } if (sum % 2 != 0) { cout << "No" << '\n'; return; } } cout << "Yes" << '\n'; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long t = 1; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; int m1[520][520]; int m2[520][520]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &m1[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &m2[i][j]); } } for (int i = 0; i < n; i++) { int x1 = 0, x2 = 0; for (int j = 0; j < m; j++) { x1 ^= m1[i][j]; x2 ^= m2[i][j]; } if (x1 ^ x2) { printf("No\n"); return 0; } } for (int i = 0; i < m; i++) { int x1 = 0, x2 = 0; for (int j = 0; j < n; j++) { x1 ^= m1[j][i]; x2 ^= m2[j][i]; } if (x1 ^ x2) { printf("No\n"); return 0; } } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); ; bool resp = true; int mat[600][600], dest[600][600]; int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> mat[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> dest[i][j]; } for (int i = 0; i < n; i++) { int linhas = 0; int colunas = 0; for (int j = 0; j < m; j++) { if (mat[i][j] != dest[i][j]) linhas++; } if (linhas % 2 == 1) resp = false; } for (int i = 0; i < m; i++) { int linhas = 0; int colunas = 0; for (int j = 0; j < n; j++) { if (mat[j][i] != dest[j][i]) linhas++; } if (linhas % 2 == 1) resp = false; } if (resp) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1000000007; const long double PI = 2 * acos(0.0); const vector<long long int> dx = {1, -1, 0, 0}; const vector<long long int> dy = {0, 0, 1, -1}; vector<long long int> ga(long long int n, bool oneIndexed = false) { vector<long long int> a; if (oneIndexed) a.push_back(0ll); for (long long int i = 0; i < n; i++) { long long int p; cin >> p; a.push_back(p); } return move(a); } vector<unsigned long long int> gau(unsigned long long int n, bool oneIndexed = false) { vector<unsigned long long int> a; if (oneIndexed) a.push_back(0llu); for (unsigned long long int i = 0; i < n; i++) { unsigned long long int p; cin >> p; a.push_back(p); } return move(a); } vector<string> gas(unsigned long long int n, bool oneIndexed = false) { vector<string> a; if (oneIndexed) a.push_back(""); for (unsigned long long int i = 0; i < n; i++) { string p; cin >> p; a.push_back(p); } return move(a); } template <typename T, typename A> void pa(vector<T, A> const &a, long long int begin = 0, long long int end = -1) { if (end == -1) end = a.size() - 1; for (long long int i = begin; i <= end; i++) { cout << a[i] << " "; } cout << "\n"; } void yes() { cout << "Yes\n"; } void no() { cout << "No\n"; } void yesno(int f) { if (f) yes(); else no(); } void solve() { long long int n, m; cin >> n >> m; vector<vector<long long int>> a(n, vector<long long int>(m)), b(n, vector<long long int>(m)); for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < m; j++) { cin >> a[i][j]; } } for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < m; j++) { cin >> b[i][j]; } } if (n == 1 && m == 1) { yesno(a[0][0] == b[0][0]); return; } else if (n == 1 && m == 2) { yesno(a[0][0] == b[0][0] && a[0][1] == b[0][1]); return; } else if (n == 2 && m == 1) { yesno(a[0][0] == b[0][0] && a[1][0] == b[1][0]); return; } for (long long int i = 0; i < n - 1; i++) { for (long long int j = 0; j < m - 1; j++) { if (a[i][j] != b[i][j]) { b[i][m - 1] = !b[i][m - 1]; b[n - 1][j] = !b[n - 1][j]; b[n - 1][m - 1] = !b[n - 1][m - 1]; } } } for (long long int i = 0; i < n; i++) { if (a[i][m - 1] != b[i][m - 1]) { no(); return; } } for (long long int i = 0; i < m; i++) { if (a[n - 1][i] != b[n - 1][i]) { no(); return; } } yes(); } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; void getint(int &v) { char ch, fu = 0; for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ; if (ch == '-') fu = 1, ch = getchar(); for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0'; if (fu) v = -v; } int n, m, x, h[500010], l[500010]; int main() { cin >> n >> m; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) getint(x), h[i] ^= x, l[j] ^= x; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) getint(x), h[i] ^= x, l[j] ^= x; for (int i = 1; i <= n; ++i) if (h[i] != 0) return puts("No"), 0; for (int j = 1; j <= m; ++j) if (l[j] != 0) return puts("No"), 0; puts("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; long long ab(long long x) { return x > 0LL ? x : -x; } long long round_up(long long x, long long y) { long long r = x / y; return r * y == x ? r : ++r; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; t = 1; while (t--) { long long a, b; cin >> a >> b; int **arr = new int *[a]; for (int i = 0; i < a; ++i) { arr[i] = new int[b]; } for (long long i = 0; i < a; i++) { for (long long j = 0; j < b; j++) { cin >> arr[i][j]; } } int **arr1 = new int *[a]; for (int i = 0; i < a; ++i) { arr1[i] = new int[b]; } for (long long i = 0; i < a; i++) { for (long long j = 0; j < b; j++) { cin >> arr1[i][j]; } } long long ty1 = 0; long long ty2 = 0; for (long long i = 0; i < a; i++) { for (long long j = 0; j < b; j++) { ty1 += arr[i][j]; ty2 += arr1[i][j]; } } if ((ty1 % 2) != (ty2 % 2)) { cout << "NO"; return 0; } for (long long i = 0; i < a; i++) { ty2 = 0; ty1 = 0; for (long long j = 0; j < b; j++) { ty1 += arr[i][j]; ty2 += arr1[i][j]; } if ((ty1 % 2) != (ty2 % 2)) { cout << "NO"; return 0; } } for (long long i = 0; i < b; i++) { ty2 = 0; ty1 = 0; for (long long j = 0; j < a; j++) { ty1 += arr[j][i]; ty2 += arr1[j][i]; } if ((ty1 % 2) != (ty2 % 2)) { cout << "NO"; return 0; } } cout << "YES"; } }
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5, INF = 1e9 + 7; long long a[505][505], b[505][505], c[505][505], i, j, m, n, p, q; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) cin >> a[i][j]; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { cin >> b[i][j]; if (b[i][j] != a[i][j]) c[i][j] = 1; } for (i = 1; i <= n; i++) { long long k = 0; for (j = 1; j <= m; j++) { if (c[i][j] == 1) k++; } if (k % 2 == 1) { cout << "No" << endl; return 0; } } for (i = 1; i <= m; i++) { long long k = 0; for (j = 1; j <= n; j++) { if (c[j][i] == 1) k++; } if (k % 2 == 1) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, m; cin >> n >> m; long long int mat1[n][m], mat2[n][m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> mat1[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> mat2[i][j]; bool exist = true; for (int i = 0; i < n; i++) { long long int cnt1 = 0, cnt2 = 0; for (int j = 0; j < m; j++) { if (mat1[i][j] == 1) cnt1++; if (mat2[i][j] == 1) cnt2++; } if (cnt1 % 2 != cnt2 % 2) exist = false; } long long int cntA = 0, cntB = 0; for (int j = 0; j < m; j++) { long long int cnt1 = 0, cnt2 = 0; for (int i = 0; i < n; i++) { if (mat1[i][j] == 1) cnt1++, cntA++; if (mat2[i][j] == 1) cnt2++, cntB++; } if (cnt1 % 2 != cnt2 % 2) exist = false; } if (cntA % 2 != cntB % 2) exist = false; cout << (exist ? "YES" : "NO") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 5e3 + 1; int a[N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]); } bool fd = true; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { int x; scanf("%d", &x); a[i][j] ^= x ^ a[i - 1][j - 1] ^ a[i - 1][j] ^ a[i][j - 1]; if (a[i][j] == 1 && (i == n || j == m)) { printf("No"); return 0; } } } printf("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; int n, m; int a[510][510], b[510][510]; int main() { ios::sync_with_stdio(false); cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j]; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> b[i][j]; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { if (a[i][j] == b[i][j]) continue; a[i][j] ^= 1; a[i][1] ^= 1; a[1][j] ^= 1; a[1][1] ^= 1; } for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (a[i][j] != b[i][j]) { cout << "No"; return 0; } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 511; long long n, m, k, h; long long a[N][N]; long long b[N][N]; long long ax[N]; long long bx[N]; long long ay[N]; long long by[N]; signed main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m; for (long long i = 1; i <= n; i++) { for (long long j = 1; j <= m; j++) { cin >> a[i][j]; } } for (long long i = 1; i <= n; i++) { for (long long j = 1; j <= m; j++) { cin >> b[i][j]; } } for (long long i = 1; i <= n; i++) { for (long long j = 1; j <= m; j++) { ay[i] = ay[i] + a[i][j]; by[i] = by[i] + b[i][j]; } ay[i] = ay[i] % 2; by[i] = by[i] % 2; while (ay[i] < 0) { ay[i] += 2; } while (by[i] < 0) { by[i] += 2; } if (ay[i] != by[i]) { cout << "No" << "\n"; return 0; } } for (long long j = 1; j <= m; j++) { for (long long i = 1; i <= n; i++) { ax[j] = ax[j] + a[i][j]; bx[j] = bx[j] + b[i][j]; } ax[j] = ax[j] % 2; bx[j] = bx[j] % 2; while (ax[j] < 0) { ax[j] += 2; } while (bx[j] < 0) { bx[j] += 2; } if (ax[j] != bx[j]) { cout << "No" << "\n"; return 0; } } cout << "Yes" << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; namespace IO { const int sz = 1 << 15; char inbuf[sz], outbuf[sz]; char *pinbuf = inbuf + sz; char *poutbuf = outbuf; inline char _getchar() { if (pinbuf == inbuf + sz) fread(inbuf, 1, sz, stdin), pinbuf = inbuf; return *(pinbuf++); } inline void _putchar(char x) { if (poutbuf == outbuf + sz) fwrite(outbuf, 1, sz, stdout), poutbuf = outbuf; *(poutbuf++) = x; } inline void flush() { if (poutbuf != outbuf) fwrite(outbuf, 1, poutbuf - outbuf, stdout), poutbuf = outbuf; } } // namespace IO inline int read() { int x = 0, p = 1; char c = IO::_getchar(); while (c < '0' || c > '9') { if (c == '-') p = -1; c = IO::_getchar(); } while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = IO::_getchar(); return x * p; } const int Maxn = 505; int A[Maxn][Maxn], B[Maxn][Maxn]; int n, m; int main() { n = read(); m = read(); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) A[i][j] = read(); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) B[i][j] = read(); for (int i = 2; i <= n; i++) { for (int j = 2; j <= m; j++) { if (A[i][j]) { A[i][1] ^= 1; A[1][j] ^= 1; A[1][1] ^= 1; } } } for (int i = 2; i <= n; i++) { for (int j = 2; j <= m; j++) { if (B[i][j]) { B[i][1] ^= 1; B[1][j] ^= 1; B[1][1] ^= 1; } } } for (int i = 1; i <= n; i++) if (A[i][1] != B[i][1]) { puts("NO"); return 0; } for (int i = 1; i <= m; i++) if (A[1][i] != B[1][i]) { puts("NO"); return 0; } puts("YES"); return ~~(0 ^ 0 ^ 0); }
#include <bits/stdc++.h> int N, M, x; int a1[503], b1[503], a2[503], b2[503]; int main() { scanf(" %d %d", &N, &M); for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { scanf(" %d", &x); a1[i] ^= x; b1[j] ^= x; } } for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { scanf(" %d", &x); a2[i] ^= x; b2[j] ^= x; } } for (int i = 0; i < N; ++i) { if (a1[i] != a2[i]) { printf("No\n"); return 0; } } for (int i = 0; i < M; ++i) { if (b1[i] != b2[i]) { printf("No\n"); return 0; } } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int mat_a[505][505]; int mat_b[505][505]; int row_a[505]; int column_a[505]; int row_b[505]; int column_b[505]; int n, m; int main() { scanf("%d%d", &n, &m); int count_a = 0; int count_b = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &mat_a[i][j]); count_a += mat_a[i][j]; } row_a[i] = (count_a & 1); count_a = 0; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &mat_b[i][j]); count_b += mat_b[i][j]; } row_b[i] = (count_b & 1); count_b = 0; } count_a = 0, count_b = 0; for (int j = 1; j <= m; j++) { for (int i = 1; i <= n; i++) { count_a += mat_a[i][j]; count_b += mat_b[i][j]; } column_a[j] = (count_a & 1); column_b[j] = (count_b & 1); count_a = 0, count_b = 0; } int flag = 0; for (int i = 1; i <= n; i++) { if (row_a[i] != row_b[i]) { flag = 1; break; } } if (!flag) { for (int j = 1; j <= m; j++) { if (column_a[j] != column_b[j]) { flag = 1; break; } } if (flag) puts("No"); else puts("Yes"); } else puts("No"); }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const double eps = 1e-9; const int inf = 1e9; int a[555][555], b[555][555]; int main() { int n, m, cnt0 = 0, cnt1 = 0; cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> b[i][j]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[i][j] != b[i][j]) { if (i == n - 1 || j == m - 1) { cout << "NO"; return 0; } a[i][j] ^= 1; a[i + 1][j] ^= 1; a[i][j + 1] ^= 1; a[i + 1][j + 1] ^= 1; } } } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; long long a[n][m], b[n][m]; long long sum1 = 0, sum2 = 0; for (long long i = 0; i < n; i++) { for (long long j = 0; j < m; j++) { cin >> a[i][j]; sum1 += a[i][j]; } } for (long long i = 0; i < n; i++) { for (long long j = 0; j < m; j++) { cin >> b[i][j]; sum2 += b[i][j]; } } if ((sum1 % 2 == 0 && sum2 % 2 == 1) || (sum1 % 2 == 1 && sum2 % 2 == 0)) { cout << "NO"; return 0; } long long r1 = 0, c1 = 0, c2 = 0, r2 = 0; for (long long i = 0; i < n; i++) { r1 = 0; r2 = 0; for (long long j = 0; j < m; j++) { r1 += a[i][j]; r2 += b[i][j]; } if ((r1 % 2 == 0 && r2 % 2 == 1) || (r1 % 2 == 1 && r2 % 2 == 0)) { cout << "NO"; return 0; } } for (long long i = 0; i < m; i++) { c1 = 0; c2 = 0; for (long long j = 0; j < n; j++) { c1 += a[j][i]; c2 += b[j][i]; } if ((c1 % 2 == 0 && c2 % 2 == 1) || (c1 % 2 == 1 && c2 % 2 == 0)) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int A[n][m], B[n][m]; for (int i = 0; i < (int)n; i++) for (int j = 0; j < (int)m; j++) cin >> A[i][j]; for (int i = 0; i < (int)n; i++) for (int j = 0; j < (int)m; j++) cin >> B[i][j]; for (int i = 0; i < (int)n - 1; i++) { for (int j = 1; j < (int)m; j++) { if (A[i][j] != B[i][j]) { A[i][0] = (A[i][0] + 1) % 2; A[i + 1][0] = (A[i + 1][0] + 1) % 2; A[i][j] = (A[i][j] + 1) % 2; A[i + 1][j] = (A[i + 1][j] + 1) % 2; } } } for (int i = 0; i < (int)n; i++) for (int j = 0; j < (int)m; j++) { if (A[i][j] != B[i][j]) { cout << "No\n"; return 0; } } cout << "Yes\n"; }
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); } template <class T> int cntbit(T s) { return __builtin_popcount(s); } template <class T> inline T gcd(T a, T b) { T r; while (b != 0) { r = a % b; a = b; b = r; } return a; } long long n, m, a[505][505], b[505][505], c[505][505]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (long long i = 1, _b = n; i <= _b; i++) for (long long j = 1, _b = m; j <= _b; j++) cin >> a[i][j]; for (long long i = 1, _b = n; i <= _b; i++) for (long long j = 1, _b = m; j <= _b; j++) cin >> b[i][j]; for (long long i = 1, _b = n; i <= _b; i++) { for (long long j = 1, _b = m; j <= _b; j++) c[i][j] = (a[i][j] ^ b[i][j]); } for (long long i = 1, _b = n; i <= _b; i++) { long long dem = 0; for (long long j = 1, _b = m; j <= _b; j++) dem += c[i][j]; if (dem & 1) { cout << "No"; return 0; } } for (long long j = 1, _b = m; j <= _b; j++) { long long dem = 0; for (long long i = 1, _b = n; i <= _b; i++) dem += c[i][j]; if (dem & 1) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const int DEBUG = 0; mt19937 gen( (unsigned)chrono::high_resolution_clock::now().time_since_epoch().count()); #pragma comment(linker, "/STACK:67108864") int main() { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; vector<vector<int>> a(h, vector<int>(w)); vector<vector<int>> b(h, vector<int>(w)); vector<int> p1(w), r1(h), p2(w), r2(h); int s1 = 0, s2 = 0; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) { cin >> a[i][j]; s1 += a[i][j]; p1[j] += a[i][j]; r1[i] += a[i][j]; } for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) { cin >> b[i][j]; s2 += b[i][j]; p2[j] += b[i][j]; r2[i] += b[i][j]; } if (s1 % 2 != s2 % 2) { cout << "No"; return 0; } for (int i = 0; i < h; i++) if (r1[i] % 2 != r2[i] % 2) { cout << "No"; return 0; } for (int i = 0; i < w; i++) if (p1[i] % 2 != p2[i] % 2) { cout << "No"; return 0; } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m; int a[505][505], b[505][505]; int ac[505], ar[505], bc[505], br[505]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &a[i][j]); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &b[i][j]); } } int pd = 1; for (int i = 1; i <= n; i++) { ar[i] = a[i][1]; br[i] = b[i][1]; for (int j = 2; j <= m; j++) { ar[i] = ar[i] ^ a[i][j]; br[i] = br[i] ^ b[i][j]; } if (ar[i] != br[i]) { pd = 0; } } for (int i = 1; i <= m; i++) { ac[i] = a[1][i]; bc[i] = b[1][i]; for (int j = 2; j <= n; j++) { ac[i] = ac[i] ^ a[j][i]; bc[i] = bc[i] ^ b[j][i]; } if (ac[i] != bc[i]) { pd = 0; } } if (pd) printf("Yes\n"); else printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &a) { static char c; int f = 0; while (((c = getchar()) < '0' || c > '9') && (c != '-')) ; if (c == '-') { a = 0; f = 1; } else { a = c - '0'; } while ((c = getchar()) <= '9' && c >= '0') a = (a << 3) + (a << 1) + c - '0'; if (f) a = -a; } int a[505][505], b[505][505], n, m; int main() { int i, j, k; scanf("%d%d", &n, &m); for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { scanf("%d", &a[i][j]); } } for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { scanf("%d", &b[i][j]); } } for (i = 1; i <= n; i++) { int op = 0; for (j = 1; j <= m; j++) { op ^= (a[i][j] ^ b[i][j]); } if (op & 1) { puts("No"); return 0; } } for (i = 1; i <= m; i++) { int op = 0; for (j = 1; j <= n; j++) { op ^= (a[j][i] ^ b[j][i]); } if (op & 1) { puts("No"); return 0; } } puts("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; vector<vector<int> > a(n, vector<int>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } int cnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int t; cin >> t; a[i][j] ^= t; cnt += a[i][j]; } } for (int i = 0; i + 1 < n; i++) { int c = 0; for (int j = 0; j < m; j++) { c += a[i][j]; a[i + 1][j] ^= a[i][j]; } if (c % 2 == 1) { cout << "No"; return 0; } } for (int i = 0; i < m; i++) { if (a[n - 1][i] == 1) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, m, i, j; cin >> n >> m; long long A[n][m]; long long B[n][m]; for (auto i = 0; i < n; i++) for (auto j = 0; j < m; j++) cin >> A[i][j]; for (auto i = 0; i < n; i++) for (auto j = 0; j < m; j++) cin >> B[i][j]; for (auto i = 0; i < n; i++) { long long cnt = 0; for (auto j = 0; j < m; j++) { if (A[i][j] != B[i][j]) cnt++; } if (cnt % 2 != 0) { cout << "No" << '\n'; return 0; } } for (auto j = 0; j < m; j++) { long long cnt = 0; for (auto i = 0; i < n; i++) { if (A[i][j] != B[i][j]) cnt++; } if (cnt % 2 != 0) { cout << "No" << '\n'; return 0; } } cout << "Yes" << '\n'; }
#include <bits/stdc++.h> using namespace std; int n, m; bool ma[501][501]; bool diff[501][501]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> ma[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { cin >> diff[i][j]; diff[i][j] = diff[i][j] != ma[i][j]; } bool duar = true; for (int i = 0; i < n; i++) { int jmlbeda = 0; for (int j = 0; j < m; j++) { if (diff[i][j]) jmlbeda++; } duar &= duar && (jmlbeda % 2 == 0); } for (int i = 0; i < m; i++) { int jmlbeda = 0; for (int j = 0; j < n; j++) { if (diff[j][i]) jmlbeda++; } duar &= jmlbeda % 2 == 0; } if (duar) cout << "Yes\n"; else cout << "No\n"; }
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { if (b == 0) return 1; long long int c = power(a, b >> 1); c = (c * c) % 1000000007; if (b & 1) return (c * a) % 1000000007; return c; } const int N = (int)1e5 + 5; int cnt[1010], a[510][510], b; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); memset(cnt, 0, sizeof(cnt)); int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> b; if (b != a[i][j]) { cnt[i]++; cnt[j + n]++; } } } bool ch = true; for (int i = 1; i < 1010; i++) { ch &= (cnt[i] % 2 == 0); } if (ch) cout << "Yes"; else cout << "No"; }
#include <bits/stdc++.h> using namespace std; void doRoutine() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); srand(322179); } signed main() { doRoutine(); int n, m; cin >> n >> m; vector<vector<int> > a(n, vector<int>(m)); vector<vector<int> > b(n, vector<int>(m)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> a[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> b[i][j]; } } bool flag = true; for (int i = 0; i < n; ++i) { int sum = 0; for (int j = 0; j < m; ++j) { sum += a[i][j] - b[i][j]; } if (abs(sum) % 2 == 1) { flag = false; } } for (int j = 0; j < m; ++j) { int sum = 0; for (int i = 0; i < n; ++i) { sum += a[i][j] - b[i][j]; } if (abs(sum) % 2 == 1) { flag = false; } } if (flag) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using Pii = pair<int, int>; using Vi = vector<int>; void run(); int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(18); run(); return 0; } int uplg(int n) { return 32 - __builtin_clz(n); } int uplg(ll n) { return 64 - __builtin_clzll(n); } void run() { int n, m; cin >> n >> m; vector<Vi> mat(n, Vi(m)); for (int i = (0); i < (n); i++) for (int j = (0); j < (m); j++) cin >> mat[i][j]; for (int i = (0); i < (n); i++) for (int j = (0); j < (m); j++) { int k; cin >> k; mat[i][j] ^= k; } for (int i = (0); i < (n); i++) { int sum = 0; for (int j = (0); j < (m); j++) sum += mat[i][j]; if (sum % 2) { cout << "No\n"; return; } } for (int i = (0); i < (m); i++) { int sum = 0; for (int j = (0); j < (n); j++) sum += mat[j][i]; if (sum % 2) { cout << "No\n"; return; } } cout << "Yes\n"; }
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename Q_temp> using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp> >; const int INF = (int)1e9; const ll LINF = (ll)4e18; const ll MOD = (ll)(1e9 + 7); const double PI = acos(-1.0); const int limit = 100010; vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0}; vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0}; inline ll CEIL(ll a, ll b) { return (a + b - 1) / b; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; int a[n][m], b[n][m]; for (ll i = 0; i < (ll)(n); ++i) for (ll j = 0; j < (ll)(m); ++j) cin >> a[i][j]; for (ll i = 0; i < (ll)(n); ++i) for (ll j = 0; j < (ll)(m); ++j) cin >> b[i][j]; bool diff[n][m]; for (ll i = 0; i < (ll)(n); ++i) for (ll j = 0; j < (ll)(m); ++j) diff[i][j] = (a[i][j] != b[i][j]); auto finish = []() { cout << ((false) ? "Yes" : "No") << endl; exit(0); }; for (ll i = 0; i < (ll)(n); ++i) { int sum = 0; for (ll j = 0; j < (ll)(m); ++j) sum += diff[i][j]; if (sum % 2 != 0) finish(); } for (ll j = 0; j < (ll)(m); ++j) { int sum = 0; for (ll i = 0; i < (ll)(n); ++i) sum += diff[i][j]; if (sum % 2 != 0) finish(); } cout << ((true) ? "Yes" : "No") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long mult(long long a, long long b, long long p = 1000000007) { long long ans = a; ans *= b; return ((ans >= p) ? ans % p : ans); } long long add(long long a, long long b, long long p = 1000000007) { long long ans = a + b; return ((ans >= p) ? ans - p : ans); } long long fpow(long long n, long long k, long long p = 1000000007) { long long r = 1; for (; k; k >>= 1) { if (k & 1) r = r * n % p; n = n * n % p; } return r; } long long inv(long long a, long long p = 1000000007) { return fpow(a, p - 2, p); } int n, m; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> m >> n; vector<vector<int> > arr1(m, vector<int>(n)); vector<vector<int> > arr2(m, vector<int>(n)); for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) cin >> arr1[i][j]; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) cin >> arr2[i][j]; vector<int> rows(m, 0); vector<int> cols(n, 0); for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (arr1[i][j] != arr2[i][j]) rows[i]++, cols[j]++; bool flag = true; for (int i = 0; i < m; i++) if (rows[i] % 2 != 0) flag = false; for (int j = 0; j < n; j++) if (cols[j] % 2 != 0) flag = false; if (!flag) { cout << "No" << endl; } else { cout << "Yes" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, m; cin >> n >> m; long long a[n][m], b[n][m], res[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> a[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> b[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) if (a[i][j] != b[i][j]) res[i][j] = 1; else res[i][j] = 0; } bool flag = false; long long sum_t = 0; for (int i = 0; i < n; i++) { long long sum_r = 0; for (int j = 0; j < m; j++) { sum_r += res[i][j]; sum_t += res[i][j]; } if (sum_r % 2 != 0) { flag = true; break; } } for (int j = 0; j < m; j++) { long long sum_c = 0; for (int i = 0; i < n; i++) { sum_c += res[i][j]; } if (sum_c % 2 != 0) { flag = true; break; } } if (flag) cout << "No"; else cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m; int a[505][505]; int b[505][505]; int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) scanf("%d", &b[i][j]); } for (int i = 1; i <= n; i++) { a[i][0] = b[i][0] = 0; for (int j = 1; j <= m; j++) { a[i][0] ^= a[i][j]; b[i][0] ^= b[i][j]; } } for (int j = 1; j <= m; j++) { a[0][j] = b[0][j] = 0; for (int i = 1; i <= n; i++) { a[0][j] ^= a[i][j]; b[0][j] ^= b[i][j]; } } bool flag = true; for (int i = 1; i <= n; i++) flag = flag && (a[i][0] == b[i][0]); for (int j = 1; j <= m; j++) flag = flag && (a[0][j] == b[0][j]); if (flag) printf("Yes\n"); else printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long expo(long long base, long long pow) { long long ans = 1; while (pow != 0) { if (pow & 1 == 1) { ans = ans * base; ans = ans % mod; } base *= base; base %= mod; pow /= 2; } return ans; } long long inv(long long x) { return expo(x, mod - 2); } int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const int M = 505; int a[M][M], b[M][M], row[M], col[M]; vector<int> r, c; int main() { int n, m; scanf("%d", &(n)); scanf("%d", &(m)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &(a[i][j])); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &(b[i][j])); if (a[i][j] != b[i][j]) { row[i]++; col[j]++; } } } bool ok = 1; for (int i = 1; i <= n; i++) { if (row[i] == 0) continue; r.push_back(row[i]); if (row[i] % 2 != 0) ok = 0; } for (int j = 1; j <= m; j++) { if (col[j] == 0) continue; c.push_back(col[j]); if (col[j] % 2 != 0) ok = 0; } if (ok == 0) { cout << "No"; return 0; } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; int a[505][505], b[505][505], n, i, j, x, m; int main() { cin >> n >> m; for (i = 0; i < n; i++) for (j = 0; j < m; j++) cin >> a[i][j]; for (i = 0; i < n; i++) for (j = 0; j < m; j++) cin >> b[i][j]; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) x = x + a[i][j]; for (j = 0; j < m; j++) x = x + b[i][j]; if (x % 2 == 1) { cout << "No" << endl; return 0; } x = 0; } for (j = 0; j < m; j++) { for (i = 0; i < n; i++) x = x + a[i][j]; for (i = 0; i < n; i++) x = x + b[i][j]; if (x % 2 == 1) { cout << "No" << endl; return 0; } x = 0; } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/stack:256000000") using namespace std; mt19937_64 gen(time(NULL)); long long const maxn = 505; long long a[maxn][maxn], b[maxn][maxn], c[maxn][maxn]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> m; for (long long i = 0; i < n; i++) { for (long long j = 0; j < m; j++) { cin >> a[i][j]; } } for (long long i = 0; i < n; i++) { for (long long j = 0; j < m; j++) { cin >> b[i][j]; c[i][j] = a[i][j] != b[i][j]; } } for (long long i = 0; i < n - 1; i++) { long long cnt = 0; for (long long j = 0; j < m; j++) { if (c[i][j]) { cnt++; } } if (cnt % 2) { cout << "No"; return 0; } for (long long j = 0; j < m; j++) { if (c[i][j]) { c[i][j] = 0; c[i + 1][j] ^= 1; } } } for (long long j = 0; j < m; j++) { if (c[n - 1][j]) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int m, n; bool a[505][505], b[505][505]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> b[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[i][j] != b[i][j]) { if (i == n || j == m) { cout << "No" << endl; return 0; } a[i][j] ^= 1; a[i + 1][j] ^= 1; a[i][j + 1] ^= 1; a[i + 1][j + 1] ^= 1; } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const string T = "RRRRPSSPRR"; string s, t, s1; int main() { string s, t; for (int i = 0; i < 10; i++) { printf("%c\n", T[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") using namespace std; static const int _ = []() { ios::sync_with_stdio(false); cin.sync_with_stdio(false); cout.sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }(); template <typename T, typename U> struct par { T x; U y; par() : x(-1), y(-1) {} par(const T& x, const U& y) : x(x), y(y) {} bool operator<(const par& other) const { if (x == other.x) return y < other.y; return x < other.x; } bool operator>(const par& other) const { if (x == other.x) return y > other.y; return x > other.x; } bool operator==(const par& other) const { return x == other.x && y == other.y; } par operator-(const par& b) const { return {x - b.x, y - b.y}; } }; template <class T> inline vector<T> rv(long long n) { vector<T> v(n); for (long long i = 0; i < (n); i++) cin >> v[i]; return v; } template <class T> inline void pv(const vector<T>& v) { for (long long i = 0; i < (v.size()); i++) cout << v[i] << " "; cout << endl; } template <class T, class U> inline void amax(T& a, const U& b) { if (a < b) a = b; } template <class T, class U> inline void amin(T& a, const U& b) { if (a > b) a = b; } template <class T, class U> inline T min(T& a, const U& b) { return a > b ? b : a; } template <class T, class U> inline T max(T& a, const U& b) { return a < b ? b : a; } const long long MOD = 1e9 + 7; const long long MOD1 = 998244353; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; long long GCD(long long a, long long b) { if (a < b) swap(a, b); while (b) { long long r = a % b; a = b; b = r; } return a; } bool issorted(vector<long long>& a, int l, int r) { for (int i = l + 1; i < r; i++) { if (a[i - 1] > a[i]) return false; } return true; } bool play(char s) { string v; cout << s << endl << flush; cin >> v; return v != "ai"; } bool check(vector<bool>& v, string s) { for (int i = 0; i < v.size(); i++) { if (v[i] != (s[i] == '1')) return false; } return true; } int main(int argc, char** argv) { vector<bool> v; v.push_back(play('R')); v.push_back(play('R')); v.push_back(play('P')); v.push_back(play('P')); v.push_back(play('S')); v.push_back(play('S')); string s; if (check(v, "001100")) { s = "PPPPPPPPPPPPPP"; } else if (check(v, "110000")) { s = "RRRRRRRRRRRRRR"; } else if (check(v, "000011")) { s = "SSSSSSSSSSSSSS"; } else if (check(v, "000110")) { s = "PSRPSRPSRPSRPS"; } else if (check(v, "001010")) { s = "RPSRPSRPSRPSRP"; } else { s = "PRSPRSPRSPRSPR"; } for (int i = 0; i < 14; i++) { v.push_back(play(s[i])); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T1> void read(T1 &r_e_a_d); template <class T1> void write(T1 w_r_i_t_e); string STR = "RRRRPSSPRR", st, s, t; int main() { for (int i = 0; i < 10; i++) { cout << STR[i]; putchar('\n'); getline(cin, st); s += (st == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { cout << t[i]; putchar('\n'); getline(cin, st); } return 0; } template <class T1> void read(T1 &r_e_a_d) { T1 k = 0; char ch = getchar(); int flag = 1; while (!(ch >= '0' && ch <= '9')) { ch = getchar(); if (ch == '-') { flag = -1; } } while ((ch >= '0' && ch <= '9')) { k = (k << 1) + (k << 3) + ch - '0'; ch = getchar(); } r_e_a_d = flag * k; } template <class T1> void write(T1 w_r_i_t_e) { if (w_r_i_t_e < 0) { putchar('-'); write(-w_r_i_t_e); } else { if (w_r_i_t_e < 10) { putchar(w_r_i_t_e + '0'); } else { write(w_r_i_t_e / 10); putchar((w_r_i_t_e % 10) + '0'); } } }
#include <bits/stdc++.h> using namespace std; int main() { string to, in, s = "RRRRPSSPRR"; for (int i = 0; i < 10; i++) { cout << s[i] << endl; cout.flush(); getline(cin, in); if (in == "ai") to += "0"; else to += "1"; } if (to == "1111000011") s = "RRRRRRRRRR"; if (to == "0000100100") s = "PPPPPPPPPP"; if (to == "0000011000") s = "SSSSSSSSSS"; if (to == "0010000010") s = "SRPSRPSRPS"; if (to == "0000110000") s = "PSRPSRPSRP"; if (to == "0000000110") s = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { cout << s[i] << endl; cout.flush(); getline(cin, in); } return 0; }
#include <bits/stdc++.h> using namespace std; const string S = "RRRRPSSPRR"; string s, s1, t; int main() { string s, t; for (int i = 0; i < 10; i++) { printf("%c\n", S[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; const string S = "RRRRPSSPRR"; string s, s1, t; int main() { string s, t; for (int i = 0; i < 10; i++) { printf("%c\n", S[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; string a, s, t = "RRPPSS"; int main() { ios_base::sync_with_stdio(false); for (int i = 0; i < 6; ++i) { cout << t[i] << endl; cin >> a; s += a[0]; } if (s == "aappaa") t = "PPP"; if (s == "aaaapp") t = "SSS"; if (s == "ppaaaa") t = "RRR"; if (s == "aaappa") t = "PSR"; if (s == "aapapa") t = "RPS"; if (s == "aaaaaa") t = "PRS"; for (int i = 0; i < 10; ++i) { cout << t[i % 3] << endl; cin >> a; } }
#include <bits/stdc++.h> using namespace std; const string possible_moves = "PRS"; map<char, char> wins_against = {{'P', 'S'}, {'R', 'P'}, {'S', 'R'}}; map<char, char> loses_against = {{'P', 'R'}, {'R', 'S'}, {'S', 'P'}}; char player[20], ai[20], result[20]; map<char, int> Count; int Round = 0; const char default_move = 'P'; int check_constant(char c) { return !(Count[wins_against[c]] || Count[loses_against[c]] || Count[c + 32]); } bool is_different(char a, char m) { return ((a < 'a') && (a != m) || (a == m + 32)); } int check_cyclic(char c) { char m = c; for (int i = Round; i--;) if (is_different(ai[i], m = wins_against[m])) break; else if (!i) return 1; m = c; for (int i = Round; i--;) { if (is_different(ai[i], m = loses_against[m])) break; else if (!i) return 1; } return 0; } bool check_tit_for_tat() { for (int i = Round; --i > 0;) if (is_different(ai[i], player[i - 1])) return 0; player[Round] = (Round > 0 ? wins_against[player[Round - 1]] : default_move); return 1; } bool check_tft_bis() { for (int i = Round; --i > 0;) if (is_different(ai[i], wins_against[player[i - 1]])) return 0; player[Round] = loses_against[player[Round - 1]]; return 1; } bool check_tft_ter() { for (int i = Round; --i > 0;) if (is_different(ai[i], loses_against[player[i - 1]])) return 0; player[Round] = player[Round - 1]; return 1; } char our_move() { if (!Round) return default_move; int i = Round - 1; if (result[i] == 'p') Count[ai[i] = loses_against[player[i]]]++; else Count[ai[i] = loses_against[player[i]] + 32]++; for (auto c : possible_moves) if (check_constant(c)) { cerr << "detected constant '" << c << "' strategy\n"; return wins_against[c]; } for (auto c : possible_moves) if (check_cyclic(c)) { cerr << "detected cyclic strategy, AI is expected to play '" << c << "'\n"; return wins_against[c]; } if (check_tit_for_tat() || check_tft_bis() || check_tft_ter()) { cerr << "detected tit for tat strategy, AI is expected to play '" << loses_against[player[Round]] << "'\n"; return player[Round]; } return default_move; } int main() { for (Round = 0; Round < 20; ++Round) { cout << (player[Round] = our_move()) << endl; cout.flush(); string verdict; getline(cin, verdict); result[Round] = verdict[0]; cerr << "Received verdict '" << result[Round] << "'\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; const char a[15] = {"RRRRPSSPRR"}; int main() { string s1, s, tmp; for (int i = 0; i < 10; ++i) { printf("%c\n", a[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? "0" : "1"); } if (s == "0000100100") tmp = "PPPPPPPPPP"; else if (s == "0000011000") tmp = "SSSSSSSSSS"; else if (s == "1111000011") tmp = "RRRRRRRRRR"; else if (s == "0010000010") tmp = "SRPSRPSRPS"; else if (s == "0000110000") tmp = "PSRPSRPSRP"; else if (s == "0000000110") tmp = "SPRSPRSPRS"; for (int i = 0; i < 10; ++i) { printf("%c\n", tmp[i]); fflush(stdout); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string u, v, s = "RRRRPSSPRR"; for (int i = 0; i < 10; i++) { cout << s[i] << endl; getline(cin, v); if (v == "ai") u += "0"; else u += "1"; } if (u == "1111000011") s = "RRRRRRRRRR"; if (u == "0000100100") s = "PPPPPPPPPP"; if (u == "0000011000") s = "SSSSSSSSSS"; if (u == "0010000010") s = "SRPSRPSRPS"; if (u == "0000110000") s = "PSRPSRPSRP"; if (u == "0000000110") s = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { cout << s[i] << endl; getline(cin, v); } return 0; }
#include <bits/stdc++.h> using namespace std; string st = "RRRRPSSPRR", s, ans, s1; int main() { for (int i = 0; i < 10; i++) { printf("%c\n", st[i]); fflush(stdout); getline(cin, s1); if (s1 == "ai") s += '0'; else s += '1'; } if (s == "0000000110") ans = "SPRSPRSPRS"; if (s == "0000011000") ans = "SSSSSSSSSS"; if (s == "0000100100") ans = "PPPPPPPPPP"; if (s == "0000110000") ans = "PSRPSRPSRP"; if (s == "0010000010") ans = "SRPSRPSRPS"; if (s == "1111000011") ans = "RRRRRRRRRR"; for (int i = 0; i < 10; i++) { printf("%c\n", ans[i]); fflush(stdout); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string T = "RRRRPSSPRR", s, t, v; for (int i = 0; i < 10; i++) { printf("%c\n", T[i]); fflush(stdout); getline(cin, v); s += (v == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, v); } return 0; }
#include <bits/stdc++.h> using namespace std; const string T = "RRRRPSSPRR"; string s, t, st; int main() { for (register int i = 0; i < 10; ++i) { printf("%c\n", T[i]); getline(cin, st); s += (st == "ai" ? '0' : '1'); } if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000000110") t = "SPRSPRSPRS"; if (s == "1111000011") t = "RRRRRRRRRR"; for (register int i = 0; i < 10; ++i) { printf("%c\n", t[i]); getline(cin, st); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char t = 'R'; vector<bool> verdicts; for (int i = 0; i < 10; ++i) { if (i == 9) { t = 'P'; } else if (i < 3) { t = 'P'; } else if (i < 6) { t = 'S'; } else { t = 'R'; } cout << t << endl; cout.flush(); string verdict; getline(cin, verdict); if (verdict == "player") { verdicts.push_back(true); } else { verdicts.push_back(false); } } bool strat = true; for (int i = 1; i < 10; i++) { if (verdicts[i - 1] and !verdicts[i] and i != 3 and i != 6 and i != 9) { strat = false; } } bool constant = false; char con; int cnt = 0; for (int i = 0; i < 10; i++) { if (i < 3 and verdicts[i]) { cnt += 1; } } if (cnt == 3) { constant = true; con = 'P'; } cnt = 0; for (int i = 0; i < 10; i++) { if (i >= 6 and verdicts[i]) { cnt += 1; } } if (cnt == 3) { constant = true; con = 'R'; } cnt = 0; for (int i = 0; i < 10; i++) { if (i >= 3 and i < 6 and verdicts[i]) { cnt += 1; } } if (cnt == 3) { constant = true; con = 'S'; } if (constant) { for (int i = 0; i < 10; ++i) { cout << con << endl; cout.flush(); string verdict; getline(cin, verdict); } } else if (strat) { for (int i = 10; i < 20; ++i) { if (i % 3 == 1) { t = 'R'; } else if (i % 3 == 2) { t = 'S'; } else { t = 'P'; } cout << t << endl; cout.flush(); string verdict; getline(cin, verdict); } } else { for (int i = 10; i < 20; ++i) { if (i % 3 == 1) { t = 'S'; } else if (i % 3 == 2) { t = 'R'; } else { t = 'P'; } cout << t << endl; cout.flush(); string verdict; getline(cin, verdict); } } }
#include <bits/stdc++.h> int f[111]; char g(char ch) { if (ch == 'R') return 'P'; if (ch == 'P') return 'S'; return 'R'; } bool o(char ch) { printf("%c\n", ch); fflush(stdout); char s[111]; scanf("%s", s); return s[0] == 'p'; } int main() { int cnt = 0; for (int i = 0; i < 6; i++) { f[i] = o('R'); cnt += f[i]; } if (cnt == 6) for (int i = 6; i < 20; i++) o('R'); else if (cnt == 3) { if (f[0]) f[6] = o('R'); else f[6] = o('P'); if (f[1]) f[7] = o('R'); else f[7] = o('P'); for (int i = 8; i < 20; i++) if (f[i % 2]) o('R'); else if (f[i % 2 + 6]) o('P'); else o('S'); } else if (cnt == 2) { for (int i = 6; i < 9; i++) f[i] = o('S'); for (int i = 9; i < 20; i++) if (f[i % 3]) o('R'); else if (f[i % 3 + 6]) o('S'); else o('P'); } else { char ch = g('R'); f[6] = o(ch); if (f[6]) { f[7] = o(ch); if (f[7]) for (int i = 8; i < 20; i++) o(ch); else for (int i = 8; i < 20; i++) { ch = g(ch); o(ch); } } else { ch = g(ch); f[7] = o(ch); if (f[7]) for (int i = 8; i < 20; i++) o(ch); else for (int i = 8; i < 20; i++) { ch = g(g(ch)); o(ch); } } } return 0; }
#include <bits/stdc++.h> using namespace std; void do_smth(int i) { switch (i % 3) { case 0: cout << "P" << endl; break; case 1: cout << "S" << endl; break; case 2: cout << "R" << endl; break; default: cout << "What?????"; } } bool Player[20] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; char Played[20] = { 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', }; void do_smth_strange(int i) { if (Player[i - 1]) { cout << Played[i - 1] << endl; Played[i] = Played[i - 1]; } else { switch (Played[i - 1]) { case 'P': cout << 'R' << endl; Played[i] = 'R'; break; case 'R': cout << 'S' << endl; Played[i] = 'S'; break; case 'S': cout << 'P' << endl; Played[i] = 'P'; break; } } cout.flush(); static string verdict; getline(cin, verdict); if (verdict == "Player") { Player[i] = true; } } int main() { cout << 'P' << endl; cout.flush(); string verdict; getline(cin, verdict); bool curious = false; bool very_curious = false; bool test_6 = false; if (verdict == "player") { for (int i = 0; i < 19; ++i) { if (!curious) cout << 'P' << endl; else { if (!test_6) do_smth(i + 1); else do_smth_strange(i); } cout.flush(); if (!test_6) { getline(cin, verdict); if (verdict == "ai") { if (!curious) { curious = true; } else { if (!very_curious) { very_curious = true; } else { test_6 = true; } } } } } } cout << 'S' << endl; cout.flush(); getline(cin, verdict); if (verdict == "player") { for (int i = 0; i < 18; ++i) { if (!curious) cout << 'S' << endl; else { if (!test_6) do_smth(i + 2); else do_smth_strange(i); } cout.flush(); if (!test_6) { getline(cin, verdict); if (verdict == "ai") { if (!curious) { curious = true; } else { if (!very_curious) { very_curious = true; } else { test_6 = true; } } } } } } for (int i = 0; i < 17; ++i) { if (!curious) cout << 'R' << endl; else { if (!test_6) do_smth(i + 3); else do_smth_strange(i); } cout.flush(); if (!test_6) { getline(cin, verdict); if (verdict == "ai") { if (!curious) { curious = true; } else { if (!very_curious) { very_curious = true; } else { test_6 = true; } } } } } }
#include <bits/stdc++.h> using namespace std; const string T = "RRRRPSSPRR"; string s, t, s1; int main() { string s, t; for (int i = 0; i < 10; i++) { printf("%c\n", T[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; namespace fastExpress { template <typename T> inline T read() { T f = 1, x = 0; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } return x * f; } template <typename T> inline void write(T x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) write(x / 10); putchar(x % 10 + '0'); } template <typename T> inline void print_char(T x, char ch) { write(x), putchar(ch); } template <typename T> inline void char_print(char ch, T x) { putchar(ch); write(x); } template <typename T> inline void print_space(T x) { print_char(x, ' '); } template <typename T> inline void space_print(T x) { char_print(' ', x); } template <typename T> inline void println(T x) { print_char(x, '\n'); } template <typename T> inline void lnprint(T x) { char_print('\n', x); } template <typename T> inline void print_array_in_range1(T* a, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) print_char(a[i], " \n"[i == r]); } template <typename T> inline void print_array_in_range2(T* a, int l, int r) { println(r - l + 1), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range3(T* a, int l, int r) { for (int(i) = (r); (i) >= (l); --(i)) print_char(a[i], " \n"[i == l]); } template <typename T> inline void print_array_in_range4(T* a, int l, int r) { println(r - l + 1), print_array_in_range3(a, l, r); } template <typename T> inline void print_array_in_range5(T* a, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) println(a[i]); } template <typename T> inline void print_array_in_range6(T* a, int l, int r) { println(r - l + 1), print_array_in_range5(a, l, r); } template <typename T> inline void print_array_in_range7(T* a, int l, int r) { for (int(i) = (r); (i) >= (l); --(i)) println(a[i]); } template <typename T> inline void print_array_in_range8(T* a, int l, int r) { println(r - l + 1), print_array_in_range7(a, l, r); } template <typename T> inline void print_array_in_range9(T* a, int l, int r) { print_space(r - l + 1), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range10(T* a, int l, int r) { print_space(r - l + 1), print_array_in_range3(a, l, r); } template <typename T> inline void print_array_in_range11(T* a, int l, int r) { print_space(r - l + 1), print_array_in_range5(a, l, r); } template <typename T> inline void print_array_in_range12(T* a, int l, int r) { print_space(r - l + 1), print_array_in_range7(a, l, r); } template <typename T> inline void print_array_in_range13(T* a, int l, int r, int n) { println(n), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range14(T* a, int l, int r, int n) { println(n), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range15(T* a, int l, int r, int n) { println(n), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range16(T* a, int l, int r, int n) { println(n), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range17(T* a, int l, int r, int n) { print_space(n), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range18(T* a, int l, int r, int n) { print_space(n), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range19(T* a, int l, int r, int n) { print_space(n), print_array_in_range1(a, l, r); } template <typename T> inline void print_array_in_range20(T* a, int l, int r, int n) { print_space(n), print_array_in_range1(a, l, r); } template <typename T> inline void print_array1(T* a, int n) { print_array_in_range1(a, 1, n); } template <typename T> inline void print_array2(T* a, int n) { println(n), print_array1(a, n); } template <typename T> inline void print_array3(T* a, int n) { print_array_in_range3(a, 1, n); } template <typename T> inline void print_array4(T* a, int n) { println(n), print_array3(a, n); } template <typename T> inline void print_array5(T* a, int n) { print_array_in_range5(a, 1, n); } template <typename T> inline void print_array6(T* a, int n) { println(n), print_array5(a, n); } template <typename T> inline void print_array7(T* a, int n) { print_array_in_range7(a, 1, n); } template <typename T> inline void print_array8(T* a, int n) { println(n), print_array7(a, n); } template <typename T> inline void print_array9(T* a, int n) { print_space(n), print_array1(a, n); } template <typename T> inline void print_array10(T* a, int n) { print_space(n), print_array3(a, n); } template <typename T> inline void print_array11(T* a, int n) { print_space(n), print_array5(a, n); } template <typename T> inline void print_array12(T* a, int n) { print_space(n), print_array7(a, n); } template <typename T> inline void vector_print(vector<T> a, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) print_char(a[i], " \n"[i == r]); } template <typename T> inline void map_print(map<T, T> a, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) print_char(a[i], " \n"[i == r]); } template <typename T> inline void stack_print(stack<T> a, char ch) { while (!a.empty()) print_char(a.top(), ch), a.pop(); } template <typename T> inline void queue_print(queue<T> a, char ch) { while (!a.empty()) print_char(a.front(), ch), a.pop(); } template <typename T> inline void pq_print(priority_queue<T> a, char ch) { while (!a.empty()) print_char(a.top(), ch), a.pop(); } inline void print_string_in_range(string s, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) putchar(s[i]); } inline void print_chars_in_range(char* a, int l, int r) { for (int(i) = (l); (i) <= (r); ++(i)) putchar(a[i]); } inline void print_allstring(string s) { print_string_in_range(s, 0, (int)s.size() - 1); } inline void filein(string s) { freopen((s + ".in").c_str(), "r", stdin); } inline void fileout(string s) { freopen((s + ".out").c_str(), "w", stdout); } inline void file(string s) { filein(s), fileout(s); } } // namespace fastExpress using namespace fastExpress; string out, in, s = "RRRRPSSPRR"; int main() { for (int(i) = (0); (i) <= (9); ++(i)) { cout << s[i] << endl; getline(cin, in); out += (in == "ai" ? "0" : "1"); } if (out == "1111000011") s = "RRRRRRRRRR"; else if (out == "0000100100") s = "PPPPPPPPPP"; else if (out == "0000011000") s = "SSSSSSSSSS"; else if (out == "0010000010") s = "SRPSRPSRPS"; else if (out == "0000110000") s = "PSRPSRPSRP"; else if (out == "0000000110") s = "SPRSPRSPRS"; for (int(i) = (0); (i) <= (9); ++(i)) { cout << s[i] << endl; getline(cin, in); } return 0; }
#include <bits/stdc++.h> using std::cin; using std::string; const string T = "RRRRPSSPRR"; string s, t, s1; int main() { string s, t; for (int i = 0; i < 10; i++) { printf("%c\n", T[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; string result, Beat, Win, Q; int main() { Beat = "RRRRPSSPRR"; for (int i = 0; i < 10; i++) { printf("%c\n", Beat[i]); fflush(stdout); getline(cin, Q); if (Q == "ai") { result += '0'; } else { result += '1'; } } if (result == "1111000011") { Win = "RRRRRRRRRR"; } if (result == "0000100100") { Win = "PPPPPPPPPP"; } if (result == "0000011000") { Win = "SSSSSSSSSS"; } if (result == "0000110000") { Win = "PSRPSRPSRP"; } if (result == "0010000010") { Win = "SRPSRPSRPS"; } if (result == "0000000110") { Win = "SPRSPRSPRS"; } for (int i = 0; i < 10; i++) { printf("%c\n", Win[i]); fflush(stdout); getline(cin, Q); } return 0; }
#include <bits/stdc++.h> using namespace std; const long long MAXN = 100005; const string T = "RRRRPSSPRR"; string s, t, s1; signed main() { string s, t; for (long long i = 0; i < 10; i++) { printf("%c\n", T[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (long long i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; string T = "RRRRPSSPRR", s, t, s1; int main(void) { string s, t; https: for (int i = 0; i < 10; i++) { printf("%c\n", T[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } }
#include <bits/stdc++.h> using namespace std; int main() { string a, w, b = "RRRRPSSPRR"; for (int i = 0; i < 10; i++) { cout << b[i] << endl; getline(cin, w); if (w == "ai") a += "0"; else a += "1"; } if (a == "1111000011") b = "RRRRRRRRRR"; if (a == "0000100100") b = "PPPPPPPPPP"; if (a == "0000011000") b = "SSSSSSSSSS"; if (a == "0010000010") b = "SRPSRPSRPS"; if (a == "0000110000") b = "PSRPSRPSRP"; if (a == "0000000110") b = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { cout << b[i] << endl; getline(cin, w); } return 0; }
#include <bits/stdc++.h> using namespace std; const string T = "RRRRPSSPRR"; string s, t, s1; int main() { string s, t; for (int i = 0; i < 10; i++) { printf("%c\n", T[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; char result[25]; int idx; char allSame() { if (idx == 7) return 'R'; if (idx == 56) return 'S'; if (idx == 56 * 8) return 'P'; return 'a'; } int main(void) { for (int i = 0; i < 3; i++) { cout << "R" << endl; cin >> result; if (result[0] == 'p') idx |= (1 << i); } for (int i = 0; i < 3; i++) { cout << "S" << endl; cin >> result; if (result[0] == 'p') idx |= (1 << (i + 3)); } for (int i = 0; i < 3; i++) { cout << "P" << endl; cin >> result; if (result[0] == 'p') idx |= (1 << (i + 6)); } char s = allSame(); if (s != 'a') { for (int i = 0; i < 11; i++) cout << s << endl; return 0; } if (idx < 2) { cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; return 0; } if (idx == 72 || idx == 73) { cout << 'R' << endl; cout << 'S' << endl; cout << 'P' << endl; cout << 'R' << endl; cout << 'S' << endl; cout << 'P' << endl; cout << 'R' << endl; cout << 'S' << endl; cout << 'P' << endl; cout << 'R' << endl; cout << 'S' << endl; return 0; } if (idx >= 256) { cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; return 0; } if (idx >= 128) { cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; return 0; } cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; cout << 'R' << endl; cout << 'P' << endl; cout << 'S' << endl; return 0; }
#include <bits/stdc++.h> using namespace std; string u, v, s = "RRRRPSSPRR"; int main() { for (int i = 0; i < 10; i++) { cout << s[i] << endl; cout.flush(); getline(cin, v); if (v == "ai") u += "0"; else u += "1"; } if (u == "1111000011") s = "RRRRRRRRRR"; if (u == "0000100100") s = "PPPPPPPPPP"; if (u == "0000011000") s = "SSSSSSSSSS"; if (u == "0010000010") s = "SRPSRPSRPS"; if (u == "0000110000") s = "PSRPSRPSRP"; if (u == "0000000110") s = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { cout << s[i] << endl; cout.flush(); getline(cin, v); } return 0; }
#include <bits/stdc++.h> using namespace std; string g = "RRRRPSSPRR", st, s, t; int main() { for (int i = 0; i < 10; i++) cout << g[i] << endl, getline(cin, st), s += st == "ai" ? '0' : '1'; if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) cout << t[i] << endl, getline(cin, st); return 0; }
#include <bits/stdc++.h> using namespace std; const string T = "RRRRPSSPRR"; string s, t, s1; int main() { for (int i = 0; i < 10; i++) { printf("%c\n", T[i]); fflush(stdout); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); fflush(stdout); getline(cin, s1); } }
#include <bits/stdc++.h> using namespace std; const string T = "RRRRPSSPRR"; string s, t, s1; int main() { string s, t; for (int i = 0; i < 10; i++) { printf("%c\n", T[i]); getline(cin, s1); s += (s1 == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { printf("%c\n", t[i]); getline(cin, s1); } return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; } return i; } template <typename T, typename U> std::ostream& operator<<(std::ostream& o, const pair<T, U>& p) { o << p.first << ' ' << p.second; return o; } template <typename T> std::ostream& operator<<(std::ostream& o, const vector<T>& t) { if (t.empty()) o << '\n'; for (size_t i = 0; i < t.size(); ++i) { o << t[i] << " \n"[i == t.size() - 1]; } return o; } template <typename T> using minheap = priority_queue<T, vector<T>, greater<T>>; template <typename T> using maxheap = priority_queue<T, vector<T>, less<T>>; template <typename T> bool in(T a, T b, T c) { return a <= b && b < c; } unsigned int logceil(long long first) { return first ? 8 * sizeof(long long) - __builtin_clzll(first) : 0; } namespace std { template <typename T, typename U> struct hash<pair<T, U>> { hash<T> t; hash<U> u; size_t operator()(const pair<T, U>& p) const { return t(p.first) ^ (u(p.second) << 7); } }; } // namespace std template <typename T, typename F> T bsh(T l, T h, const F& f) { T r = -1, m; while (l <= h) { m = (l + h) / 2; if (f(m)) { l = m + 1; r = m; } else { h = m - 1; } } return r; } template <typename F> double bshd(double l, double h, const F& f, double p = 1e-9) { unsigned int r = 3 + (unsigned int)log2((h - l) / p); while (r--) { double m = (l + h) / 2; if (f(m)) { l = m; } else { h = m; } } return (l + h) / 2; } template <typename T, typename F> T bsl(T l, T h, const F& f) { T r = -1, m; while (l <= h) { m = (l + h) / 2; if (f(m)) { h = m - 1; r = m; } else { l = m + 1; } } return r; } template <typename F> double bsld(double l, double h, const F& f, double p = 1e-9) { unsigned int r = 3 + (unsigned int)log2((h - l) / p); while (r--) { double m = (l + h) / 2; if (f(m)) { h = m; } else { l = m; } } return (l + h) / 2; } template <typename T> T gcd(T a, T b) { if (a < b) swap(a, b); return b ? gcd(b, a % b) : a; } template <typename T> class vector2 : public vector<vector<T>> { public: vector2() {} vector2(size_t a, size_t b, T t = T()) : vector<vector<T>>(a, vector<T>(b, t)) {} }; template <typename T> class vector3 : public vector<vector2<T>> { public: vector3() {} vector3(size_t a, size_t b, size_t c, T t = T()) : vector<vector2<T>>(a, vector2<T>(b, c, t)) {} }; template <typename T> class vector4 : public vector<vector3<T>> { public: vector4() {} vector4(size_t a, size_t b, size_t c, size_t d, T t = T()) : vector<vector3<T>>(a, vector3<T>(b, c, d, t)) {} }; template <typename T> class vector5 : public vector<vector4<T>> { public: vector5() {} vector5(size_t a, size_t b, size_t c, size_t d, size_t e, T t = T()) : vector<vector4<T>>(a, vector4<T>(b, c, d, e, t)) {} }; class GAITakeover { public: void solve(istream& cin, ostream& cout) { cout << "R\nR\nS\nS\nP\nP\nR" << endl; vector<string> S(7); cin >> S; map<char, char> A; if (S[1] == "player") { A['R'] = 'R'; } else if (S[2] == "player") { A['R'] = 'S'; } else { A['R'] = 'P'; } if (S[3] == "player") { A['S'] = 'S'; } else if (S[4] == "player") { A['S'] = 'P'; } else { A['S'] = 'R'; } if (S[5] == "player") { A['P'] = 'P'; } else if (S[6] == "player") { A['P'] = 'R'; } else { A['P'] = 'S'; } char last = 'P'; for (int i = 0; i < 13; ++i) { last = A[last]; cout << last << endl; } } }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); GAITakeover solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; }
#include <bits/stdc++.h> using namespace std; const string T = "RRRRPSSPRR"; string s, t, s1; int main() { string s, t; for (register unsigned i(0); i < 10; i++) printf("%c\n", T[i]), fflush(stdout), getline(cin, s1), s += s1 == "ai" ? '0' : '1'; if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (register unsigned i = 0; i < 10; i++) printf("%c\n", t[i]), fflush(stdout), getline(cin, s1); return 0; }
#include <bits/stdc++.h> using namespace std; const string S = "RRRRPSSPRR"; string s, f, t; int main() { for (int i = 0; i < 10; i++) { cout << S[i] << endl; fflush(stdout); getline(cin, f); s += (f == "ai" ? '0' : '1'); } if (s == "0000100100") t = "PPPPPPPPPP"; if (s == "0000011000") t = "SSSSSSSSSS"; if (s == "1111000011") t = "RRRRRRRRRR"; if (s == "0010000010") t = "SRPSRPSRPS"; if (s == "0000110000") t = "PSRPSRPSRP"; if (s == "0000000110") t = "SPRSPRSPRS"; for (int i = 0; i < 10; i++) { cout << t[i] << endl; fflush(stdout); getline(cin, f); } return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF = 999999999999999999; const double PI = acos(-1.0); void stop() { exit(0); } int main() { ios::sync_with_stdio(false); cout << "R\nR\nS\nS\nP\nP\nR" << endl; vector<string> S(7); for (long long i = 0; i < 7; i++) cin >> S[i]; map<char, char> A; if (S[1] == "player") { A['R'] = 'R'; } else if (S[2] == "player") { A['R'] = 'S'; } else { A['R'] = 'P'; } if (S[3] == "player") { A['S'] = 'S'; } else if (S[4] == "player") { A['S'] = 'P'; } else { A['S'] = 'R'; } if (S[5] == "player") { A['P'] = 'P'; } else if (S[6] == "player") { A['P'] = 'R'; } else { A['P'] = 'S'; } char last = 'P'; for (int i = 0; i < 13; ++i) { last = A[last]; cout << last << endl; } stop(); }