#if __INCLUDE_LEVEL__ == 0 #include using namespace std; #include __BASE_FILE__ namespace { int get_rank(vector> a) { vector b(a.size()); vector x(a[0].size()); return kactl::solveLinear(a, b, x); } void solve() { int l, m, n; cin >> tie(l, m, n); vector a(l, vector(m)); vector b(m, vector(n)); cin >> tie(a, b); vector c(l, vector(n)); for (int i : rep(l)) { for (int k : rep(m)) { for (int j : rep(n)) { c[i][j] += a[i][k] * b[k][j]; } } } for (int i : rep(l)) { for (int j : rep(n)) { if (kactl::eps < abs(c[i][j])) { print("No"); return; } } } print(m - get_rank(a) == get_rank(b) ? "Yes" : "No"); } } // namespace int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); } #else // __INCLUDE_LEVEL__ #define assert(expr) (expr) || (__builtin_unreachable(), 0) template bool chmin(T& x, U&& y) { return y < x && (x = forward(y), true); } template bool chmax(T& x, U&& y) { return x < y && (x = forward(y), true); } namespace std { template istream& operator>>(istream& is, pair& p) { return is >> p.first >> p.second; } template istream& operator>>(istream& is, tuple& t) { return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t); } template istream& operator>>(istream& is, tuple&& t) { return is >> t; } template >* = nullptr> auto operator>>(istream& is, R&& r) -> decltype(is >> *begin(r)) { for (auto&& e : r) { is >> e; } return is; } template ostream& operator<<(ostream& os, const pair& p) { return os << p.first << ' ' << p.second; } template ostream& operator<<(ostream& os, const tuple& t) { auto f = [&os](const auto&... xs) -> ostream& { [[maybe_unused]] auto sep = ""; ((os << exchange(sep, " ") << xs), ...); return os; }; return apply(f, t); } template >* = nullptr> auto operator<<(ostream& os, R&& r) -> decltype(os << *begin(r)) { auto sep = ""; for (auto&& e : r) { os << exchange(sep, " ") << e; } return os; } } // namespace std template void print(Ts&&... xs) { cout << tie(xs...) << '\n'; } inline auto rep(int l, int r) { return views::iota(min(l, r), r); } inline auto rep(int n) { return rep(0, n); } inline auto rep1(int l, int r) { return rep(l, r + 1); } inline auto rep1(int n) { return rep(1, n + 1); } inline auto per(int l, int r) { return rep(l, r) | views::reverse; } inline auto per(int n) { return per(0, n); } inline auto per1(int l, int r) { return per(l, r + 1); } inline auto per1(int n) { return per(1, n + 1); } // https://github.com/kth-competitive-programming/kactl namespace kactl { #define rep(i, a, b) for (int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; /** * Author: Per Austrin, Simon Lindholm * Date: 2004-02-08 * License: CC0 * Description: Solves $A * x = b$. If there are multiple solutions, an * arbitrary one is returned. Returns rank, or -1 if no solutions. Data in $A$ * and $b$ is lost. Time: O(n^2 m) Status: tested on kattis:equationsolver, and * bruteforce-tested mod 3 and 5 for n,m <= 3 */ typedef vector vd; const double eps = 1e-12; int solveLinear(vector& A, vd& b, vd& x) { int n = sz(A), m = sz(x), rank = 0, br, bc; if (n) assert(sz(A[0]) == m); vi col(m); iota(all(col), 0); rep(i, 0, n) { double v, bv = 0; rep(r, i, n) rep(c, i, m) if ((v = fabs(A[r][c])) > bv) br = r, bc = c, bv = v; if (bv <= eps) { rep(j, i, n) if (fabs(b[j]) > eps) return -1; break; } swap(A[i], A[br]); swap(b[i], b[br]); swap(col[i], col[bc]); rep(j, 0, n) swap(A[j][i], A[j][bc]); bv = 1 / A[i][i]; rep(j, i + 1, n) { double fac = A[j][i] * bv; b[j] -= fac * b[i]; rep(k, i + 1, m) A[j][k] -= fac * A[i][k]; } rank++; } x.assign(m, 0); for (int i = rank; i--;) { b[i] /= A[i][i]; x[col[i]] = b[i]; rep(j, 0, i) b[j] -= A[j][i] * b[i]; } return rank; // (multiple solutions if rank < m) } #undef sz #undef all #undef rep } // namespace kactl #endif // __INCLUDE_LEVEL__