text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0); int n; cin >> n; int arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (arr[i][j] != 1) { bool found = 0; for (int k = 0; k < n; k++) { if (k != j) { int s = arr[i][j] - arr[i][k]; for (int l = 0; l < n; l++) { if (arr[l][j] == s) { found = 1; } } } } if (!found) { cout << "No" << '\n'; return 0; } } } } cout << "Yes" << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int a[n][n]; bool flag = true; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> a[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] == 1) continue; else { flag = false; for (int k = 0; k < n; k++) { if (k == i) continue; long long int x, y; x = a[k][j]; for (int l = 0; l < n; l++) { if (l == j) continue; y = a[i][l]; if (x + y == a[i][j]) { flag = true; break; } } if (flag) break; } } if (flag == false) break; } if (flag == false) break; } if (flag) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int i, j, n, a[51][51], one = 0; cin >> n; long long int row[100001], col[100001]; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { cin >> a[i][j]; if (a[i][j] == 1) one++; } } if (one == n * n) { cout << "Yes"; return 0; } long long int found = 0; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (a[i][j] == 1) continue; for (long long int t = 1; t <= n; t++) { found = 0; for (long long int s = 1; s <= n; s++) { if (a[i][s] + a[t][j] == a[i][j]) { found = 1; break; } } if (found) break; } if (found) continue; else { cout << "No"; return 0; } } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> int main() { int n, s[51][51] = {{0}}, p[51 * 51][2] = {{0}}, j, i, ju = 0; scanf("%d", &n); for (j = 1; j <= n; j++) for (i = 1; i <= n; i++) { scanf("%d", &s[j][i]); if (s[j][i] != 1) p[ju][0] = j, p[ju][1] = i, ju++; } if (n == 1) { if (s[1][1] == 1) printf("Yes\n"); else printf("No\n"); } else if (ju == 0) printf("Yes\n"); else { int k; for (k = 0; k < ju; k++) { int t = 1; for (j = 1; j <= n && t; j++) { for (i = 1; i <= n && t; i++) { if (s[p[k][0]][p[k][1]] == s[p[k][0]][i] + s[j][p[k][1]]) t = 0; } } if (t) { printf("No\n"); return 0; } } printf("Yes\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; long long t[50][50]; int n; bool verif(int i, int j) { for (int a = 0; a < n; ++a) for (int b = 0; b < n; ++b) if (t[i][a] + t[b][j] == t[i][j] && a != j && b != i) return 1; return 0; } int main() { cin >> n; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cin >> t[i][j]; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) if (t[i][j] != 1 && !verif(i, j)) { cout << "No"; return 0; } cout << "Yes"; return 0; }
#include <bits/stdc++.h> int n, k, m, q; using namespace std; int main() { cin >> n; int** a = new int*[n]; for (int i = 0; i < n; i++) a[i] = new int[n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; int** sign = new int*[n]; for (int i = 0; i < n; i++) sign[i] = new int[n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) sign[i][j] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int x = a[i][j]; if (x == 1) { sign[i][j] = 1; goto lbl; } for (int s = 0; s < n; s++) for (int t = 0; t < n; t++) if (x == a[i][s] + a[t][j]) if (i != t && j != s) { sign[i][j] = 1; goto lbl; } lbl:; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (sign[i][j] == 0) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int a[60][60]; int n; bool check(int x, int y) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[x][i] + a[j][y] == a[x][y]) return true; } } return false; } int main() { cin >> n; memset(a, 0, sizeof(a)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cin >> a[i][j]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[i][j] != 1) { if (check(i, j) == true) continue; else { cout << "No" << endl; return 0; } } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n; int a[55][55]; int main() { cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] == 1) continue; bool works = false; for (int s = 0; s < n; s++) { if (works) break; for (int t = 0; t < n; t++) { if (a[i][s] + a[t][j] == a[i][j]) { works = true; break; } } } if (!works) { cout << "No\n"; return 0; } } } cout << "Yes\n"; }
#include <bits/stdc++.h> using namespace std; int a[100][100]; int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) cin >> a[i][j]; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (a[i][j] == 1) continue; bool find = false; for (int k = 1; k <= n; ++k) { for (int m = 1; m <= n; ++m) { if (k == j || m == i) continue; if (a[i][k] + a[m][j] == a[i][j]) { find = true; break; } } } if (!find) { cout << "No" << endl; exit(0); } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int i, j, k, l, flag; int arr[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { cin >> arr[i][j]; } } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (arr[i][j] == 1) continue; flag = 0; for (k = 0; k < n && flag == 0; k++) { if (arr[i][k] > arr[i][j]) continue; for (l = 0; l < n && flag == 0; l++) { if (arr[i][k] + arr[l][j] == arr[i][j]) flag = 1; } } if (flag != 1) { cout << "No"; return 0; } } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 9; const int Mod = 1e9 + 7; inline int scan() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } inline long long scan(long long x) { int f = 1; char ch = getchar(); x = 0; while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int n, m; int ans, tp; int mp[55][55], mk; void solve() { n = scan(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) mp[i][j] = scan(); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (mp[i][j] != 1) { mk = 0; for (int l = 1; l <= n; l++) { for (int k = 1; k <= n; k++) { if (mp[i][j] == mp[l][j] + mp[i][k]) mk = 1; } } if (!mk) { cout << "NO" << endl; return; } } } } cout << "YES" << endl; } int main() { int t = 1; for (int i = 1; i <= t; i++) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int arr[55][55]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", &arr[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (arr[i][j] != 1) { bool found = false; for (int k = 0; k < n && !found; k++) { for (int l = 0; l < n && !found; l++) { if (i == l || k == j) continue; if (arr[i][k] + arr[l][j] == arr[i][j]) { found = true; } } } if (!found) { printf("No\n"); return 0; } } } } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (arr[i][j] != 1) { int f = 0; for (int k = 0; k < n; k++) { for (int l = 0; l < n; l++) { if (arr[i][k] + arr[l][j] == arr[i][j] && !(l == i && k == j)) { f = 1; break; } } if (f == 1) { break; } } if (f == 0) { cout << "No" << endl; return 0; } } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int i, j, k, l, n, a[52][52], flag[2510] = {0}; while (cin >> n) { for (i = 0; i < n; i++) for (j = 0; j < n; j++) cin >> a[i][j]; for (i = 0; i < n; i++) for (j = 0; j < n; j++) for (k = 0; k < n; k++) for (l = 0; l < n; l++) { if (a[i][j] == 1) flag[j + i * n] = 1; if (a[i][j] == a[i][k] + a[l][j] && k != j && l != i) flag[j + i * n] = 1; } for (i = 0; i < n * n; i++) if (flag[i] == 0) { cout << "No" << endl; return 0; } cout << "Yes" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n][n]; int i, j, flag = 0, flag2 = 0; for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { cin >> a[i][j]; } } int k, l; int ct = 0; for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { if (a[i][j] != 1) { flag = 0; for (k = 0; k < n; ++k) { for (l = 0; l < n; ++l) { if (a[i][k] + a[l][j] == a[i][j]) { flag = 1; } } } if (flag == 0) { ct++; } } } } if (ct == 0) { cout << "Yes\n"; } else { cout << "No\n"; } }
#include <bits/stdc++.h> int main() { bool flag = true; int n, t; int mat[50][50]; std::cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { std::cin >> t; mat[i][j] = t; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { bool f = false; int current = mat[i][j]; if (current == 1) continue; for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { if (mat[x][j] == current || mat[i][y] == current) continue; if (mat[x][j] + mat[i][y] == current) { f = true; break; } } } if (f == false) { flag = false; break; } } } std::cout << (flag ? "Yes" : "No"); return 0; }
#include <bits/stdc++.h> using namespace std; int ara[100][100]; int main() { int i, j, k; int n, a, b, flag; cin >> n; for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) cin >> ara[i][j]; for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) { flag = 0; if (ara[i][j] == 1) continue; for (a = 0; a < n; ++a) { for (b = 0; b < n; ++b) { if (ara[i][a] + ara[b][j] == ara[i][j]) flag = 1; } } if (!flag) { cout << "No" << endl; return 0; } } } cout << "Yes" << endl; }
#include <bits/stdc++.h> using namespace std; int grid[100][100]; int n; bool check(int x, int y) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (grid[x][i] + grid[j][y] == grid[x][y]) return 0; } } return 1; } int main() { while (~scanf("%d", &n)) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &grid[i][j]); } } int flag = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (grid[i][j] != 1) { if (check(i, j)) flag = 0; } } } if (flag) printf("Yes\n"); else printf("No\n"); } }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, s, t; int cell = 0; cin >> n; int a[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } for (i = 0; i < n; i++) for (j = 0; j < n; j++) { cell = 0; for (s = 0; s < n; s++) for (t = 0; t < n; t++) if (a[i][j] == a[i][s] + a[t][j]) cell = 1; if (a[i][j] != 1 && cell == 0) return cout << "No", 0; } cout << "Yes", 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 300005; int32_t main() { long long tc = 1; while (tc--) { long long n; cin >> n; long long a[n][n]; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) cin >> a[i][j]; } long long flag = 0; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { if (a[i][j] == 1) continue; else { long long flag1 = 0; for (long long k = 0; k < n; k++) { for (long long l = 0; l < n; l++) { if (a[k][j] + a[i][l] == a[i][j]) flag1++; } } if (flag1 == 0) flag++; } } } if (flag) cout << "No"; else cout << "Yes"; } }
#include <bits/stdc++.h> using namespace std; bool IsPowerOfTwo(long long int x) { return (x != 0) && ((x & (x - 1)) == 0); } long long int poer(long long int a, long long int b) { long long int rs = 1; while (b > 0) { if (b & 1) rs *= a; a *= a; b /= 2; } return rs; } long long int mod_poer(long long int a, long long int b, long long int mo) { long long int rs = 1; while (b > 0) { if (b & 1) rs = (rs * a) % mo; a = (a * a) % mo; b /= 2; } return rs % mo; } long long int d, x, y; void ext_euclid(long long int a, long long int b) { if (b == 0) { d = a; x = 1; y = 0; } else { ext_euclid(b, a % b); long long int temp = x; x = y; y = temp - (a / b) * y; } } long long int mod_inverse1(long long int a, long long int m) { ext_euclid(a, m); return (x % m + m) % m; } long long int mod_inverse2(long long int a, long long int m) { return mod_poer(a, m - 2, m); } long long int gcd(long long int a, long long int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n; cin >> n; long long int mat[55][55]; for (long long int i = 0; i < n; i++) for (long long int j = 0; j < n; ++j) cin >> mat[i][j]; set<long long int> s[2550]; long long int co = 0; for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < n; ++j) { { for (long long int g = 0; g < n; ++g) for (long long int h = 0; h < n; ++h) { if (g == i || h == j) continue; else { s[co].insert(mat[i][h] + mat[g][j]); } } } co++; } } long long int cnt = 0; for (long long int i = 0; i < n; i++) for (long long int j = 0; j < n; ++j) { if (mat[i][j] != 1 && s[cnt].find(mat[i][j]) == s[cnt].end()) { cout << "No" << endl; return 0; } cnt++; } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[55][55]; int main() { ios::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cin >> a[i][j]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[i][j] == 1) continue; int flag = 0; for (int ii = 1; ii <= n; ii++) { for (int jj = 1; jj <= n; jj++) { if (a[ii][j] + a[i][jj] == a[i][j]) flag = 1; } } if (!flag) { cout << "No" << endl; return 0; } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void sol() { cout << "Hi"; } int main() { int n; cin >> n; int d[n][n]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> d[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { bool fl = 0; if (d[i][j] != 1) { for (int t = 0; t < n && !fl; ++t) { for (int k = 0; k < n && !fl; ++k) { if (i != k && j != t) if (d[i][j] == d[i][t] + d[k][j]) { fl = 1; } } } } else fl = 1; if (!fl) { cout << "No"; return 0; } } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int a[59][59]; int main() { int n; while (~scanf("%d", &n)) { int i1, j1; int ans = 0, flag = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &a[i][j]); } } for (i1 = 1; i1 <= n; i1++) { for (j1 = 1; j1 <= n; j1++) { if (a[i1][j1] == 1) continue; flag = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[i1][j1] == a[i1][i] + a[j][j1]) { flag = 1; break; } } if (flag) break; } if (flag == 0) break; } if (flag == 0) break; } if (flag) printf("Yes\n"); else printf("No\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; int a[53][53]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> a[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] != 1) { int x = i, y = j, flag = 0; for (int p = 0; p < n; p++) { for (int q = 0; q < n; q++) { if (p != x && q != j && a[p][y] + a[x][q] == a[i][j]) flag = 1; } } if (!flag) { cout << "No"; return 0; } } } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e2; int n; bool ok[maxn][maxn]; int a[maxn][maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> a[i][j]; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { if (a[i][j] == 1) continue; for (int ii = 1; ii <= n; ii++) for (int jj = 1; jj <= n; jj++) { if (ii != i && j != jj && a[ii][j] + a[i][jj] == a[i][j]) { ok[i][j] = 1; } } if (!ok[i][j]) return cout << "No", 0; } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int lab[55][55]; int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &lab[i][j]); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { bool flag = 0; if (lab[i][j] != 1) { for (int k = 1; k <= n; k++) { if (flag) break; if (k == i) continue; if (lab[k][j] < lab[i][j]) { for (int l = 1; l <= n; l++) { if (l == j) continue; if (lab[i][l] < lab[i][j]) if (lab[i][l] == lab[i][j] - lab[k][j]) { flag = 1; break; } } } } if (!flag) { printf("No\n"); return 0; } } } } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int s[55][55]; int n, i, j, k, l, tag, jg; cin >> n; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) cin >> s[i][j]; jg = 1; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) { tag = 0; for (k = 1; k <= n; k++) for (l = 1; l <= n; l++) if (s[i][k] + s[l][j] == s[i][j]) tag++; if ((s[i][j] != 1) && (tag == 0)) jg = 0; } if (jg == 1) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 55; int a[maxn][maxn]; int n; int main() { cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]); bool flag = true; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { if (a[i][j] > 1) { bool f = 0; for (int k = 1; k <= n; k++) if (k != i) { for (int l = 1; l <= n; l++) if (l != j) { if (a[k][j] + a[i][l] == a[i][j]) f = 1; } } flag &= f; } } if (flag) { cout << "Yes" << endl; } else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (arr[i][j] == 1) continue; bool good = false; for (int k = 0; k < n; k++) { for (int l = 0; l < n; l++) { if (arr[k][j] + arr[i][l] == arr[i][j]) { good = true; } } } if (!good) { cout << "No" << endl; return 0; } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; constexpr int INF = numeric_limits<int>::max() / 2; constexpr long long LINF = numeric_limits<long long>::max() / 3; struct Double { double d; explicit Double(double x) : d(x) {} }; ostream& operator<<(ostream& os, const Double x) { os << fixed << setprecision(20) << x.d; return os; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << "["; for (const auto& v : vec) { os << v << ","; } os << "]"; return os; } template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <typename T> ostream& operator<<(ostream& os, const set<T>& st) { os << "{"; for (T v : st) os << v << ","; os << "}"; return os; } long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } constexpr double eps = 1e-10; constexpr long long mod = 1e9 + 7; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; int n; long long a[64][64]; int main() { cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; for (int x = 0; x < n; x++) for (int y = 0; y < n; y++) if (a[x][y] != 1) { bool ok = false; for (int s = 0; s < n; s++) { for (int t = 0; t < n; t++) { if (a[x][s] + a[t][y] == a[x][y]) { ok = true; break; } } if (ok) break; } if (!ok) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <bits/stdc++.h> using namespace std; int num[50 + 5][50 + 5]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%d", &num[i][j]); int flag; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { flag = 0; if (num[i][j] == 1) continue; else { for (int k = 0; k < n; k++) { if (k == j) continue; int t = num[i][j] - num[i][k]; for (int l = 0; l < n; l++) { if (l == i) continue; if (t == num[l][j]) { flag = 1; break; } } if (flag) break; } } if (!flag) return 0 * printf("No\n"); } } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int a[55][55]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", &a[i][j]); } } int fg = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] != 1) { int flag = 0; for (int k = 0; k < n; k++) { for (int p = 0; p < n; p++) { if (a[i][k] + a[p][j] == a[i][j]) { flag = 1; break; } } if (flag) break; } if (!flag) { fg = 0; break; } } } } puts(fg ? "Yes" : "No"); }
#include <bits/stdc++.h> template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) { std::cout << name << " = " << arg1 << std::endl; } template <typename Arg1, typename... Args> void ZZ(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " = " << arg1; ZZ(comma, args...); } using namespace std; long long n, m, q; vector<vector<long long> > ar; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; ar.resize(n); for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { long long t; cin >> t; ar[i].push_back(t); } } for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { if (ar[i][j] != 1) { bool flag = false; for (long long k = 0; k < n; k++) { if (k != i) { for (long long l = 0; l < n; l++) { if (l != j) { if (ar[k][j] + ar[i][l] == ar[i][j]) { flag = true; break; } } } } if (flag == true) { break; } } if (!flag) { cout << "No" << endl; return 0; } } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int t[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> t[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (t[i][j] != 1) { bool yes = false; for (int s = 0; s < n && !yes; s++) { for (int p = 0; p < n && !yes; p++) { if (t[i][j] == t[i][s] + t[p][j]) yes = true; } } if (!yes) { cout << "No" << endl; return 0; } } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[55][55]; int n; int main(int argc, char* argv[]) { scanf("%d", &n); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]); } bool ans = true; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (a[i][j] == 1) continue; bool flag = false; for (int p = 0; p < n; ++p) { for (int q = 0; q < n; ++q) { if (a[i][p] + a[q][j] == a[i][j]) { flag = true; break; } } if (flag) break; } if (!flag) { ans = false; break; } } if (!ans) break; } if (ans) printf("Yes\n"); else printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0, c = 0, flag = 0; cin >> n; vector<vector<int> > a(n, vector<int>(n, 0)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { cin >> a[i][j]; if (a[i][j] != 1) c++; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] != 1) { for (int k = 0; k < n; k++) { for (int l = 0; l < n; l++) { if (a[i][j] == a[k][j] + a[i][l]) { flag = 1; break; } } if (flag == 1) break; } } if (flag == 1) count++; flag = 0; } } if (count == c) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; int a[51][51]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> a[i][j]; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (a[i][j] != 1) { bool f = false; for (int i1 = 1; i1 <= n; i1++) for (int j1 = 1; j1 <= n; j1++) if (i != i1 and j != j1 and a[i][j] == a[i][j1] + a[i1][j]) f = true; if (f == false) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x7FFFFFFF; int main() { int n, i, j, k, c, a[50][50], status; cin >> n; for (int i = 0; i < (n); i++) { for (int j = 0; j < (n); j++) { cin >> a[i][j]; } } for (int i = 0; i < (n); i++) { for (int j = 0; j < (n); j++) { if (a[i][j] == 1) continue; status = 0; for (int k = 0; k < (n); k++) { if (k == i) continue; for (int c = 0; c < (n); c++) { if (c == j) continue; int sum = a[k][j] + a[i][c]; if (sum == a[i][j]) { status = 1; break; } } if (status == 1) break; } if (status != 1) { cout << "No" << "\n"; return 0; } } } cout << "Yes" << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int n; int mat[51][51]; int ok[51][51]; int main(void) { cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> mat[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (mat[i][j] > 1) { for (int k = 0; k < n; ++k) { for (int l = 0; l < n; ++l) { if (mat[i][k] + mat[l][j] == mat[i][j] and k != j and l != i) { ok[i][j] = true; } } } } } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (mat[i][j] > 1 and !ok[i][j]) { cout << "No\n"; return 0; } } } cout << "Yes\n"; return 0; }
#include <bits/stdc++.h> using namespace std; long long int n, m, k, x; long long int arr[51][51]; int main() { cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if (arr[i][j] == 1) continue; bool f = 0; { for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { if (arr[i][x] + arr[y][j] == arr[i][j]) { f = 1; break; } } if (f) break; } } if (!f) { cout << "No"; return 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> int main() { int i, j, s, t; int flag = 0; int n; scanf("%d", &n); int a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%d", &a[i][j]); } } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { flag = 0; if (a[i][j] != 1) { for (s = 0; s < n; s++) { for (t = 0; t < n; t++) { if (a[i][t] + a[s][j] == a[i][j]) { flag = 1; break; } } if (flag) break; } if (!flag) { printf("No"); return 0; } } } } printf("Yes"); return 0; }
#include <bits/stdc++.h> int main() { int n, i, k, j, l, m = 0, o = 0, s = 0, x = 0, y; scanf("%d", &n); int a[n][n]; for (i = 0; i < n; i++) for (j = 0; j < n; j++) scanf(" %d", &a[i][j]); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (a[i][j] != 1) { x++; for (k = 0; k < n; k++) { m = 0; for (l = 0; l < n; l++) { s = a[l][j] + a[i][k]; if (s == a[i][j]) { m = 1; o++; break; } } if (m == 1) break; } } } } if (x == o) printf("YES"); else printf("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int grid[100][100] = {}; int main() { int n; cin >> n; for (long long i = 0; i < n; ++i) { for (long long q = 0; q < n; ++q) { cin >> grid[i][q]; } } for (long long i = 0; i < n; ++i) { for (long long q = 0; q < n; ++q) { if (grid[i][q] != 1) { for (long long j = 0; j < n; ++j) { for (long long t = 0; t < n; ++t) { if (grid[i][q] == grid[i][j] + grid[t][q]) goto ok; } } cout << "NO" << endl; return 0; } ok:; } } cout << "YES" << endl; }
#include <bits/stdc++.h> using namespace std; long long int grid[50][50]; int main() { bool all_ok = true; long long int n; scanf("%lld", &n); for (long long int i_n = 0; i_n < n; i_n++) { for (long long int j_n = 0; j_n < n; j_n++) { scanf("%lld", &grid[i_n][j_n]); } } for (long long int i_n = 0; i_n < n; i_n++) { for (long long int j_n = 0; j_n < n; j_n++) { if (grid[i_n][j_n] != 1) { long long int temp = grid[i_n][j_n]; bool found = false; for (long long int k_n = 0; k_n < n; k_n++) { for (long long int l_n = 0; l_n < n; l_n++) { if (grid[i_n][k_n] + grid[l_n][j_n] == temp) { found = true; } } } if (!found) all_ok = false; } } } if (all_ok) { printf("Yes\n"); } else { printf("No\n"); } }
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; int a[MAXN][MAXN]; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]); } bool flag = 1; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (a[i][j] == 1) continue; bool now = 0; for (int k = 1; k <= n; ++k) { if (k == i) continue; for (int l = 1; l <= n; ++l) { if (l == j) continue; if (a[k][j] + a[i][l] == a[i][j]) { now = 1; goto nex; } } } nex: if (!now) { flag = 0; goto out; } } } out: printf("%s", flag ? "Yes" : "No"); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 55; int n; int grid[N][N]; bool ok(int x, int y) { if (grid[x][y] == 1) return true; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if (i == x || j == y) continue; if (grid[i][y] + grid[x][j] == grid[x][y]) return true; } return false; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%d", grid[i] + j); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (!ok(i, j)) { printf("No\n"); return 0; } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; void add_edge(vector<long long> adj[], long long a, long long b) { adj[a].push_back(b); adj[b].push_back(a); } class myComparator { public: int operator()(int p1, int p2) { return p1 > p2; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long n; long long arr[100][100]; cin >> n; for (long long i = 0; i < n; i++) for (long long j = 0; j < n; j++) cin >> arr[i][j]; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { bool flag = false; if (arr[i][j] != 1) { for (long long k = 0; k < n; k++) { for (long long t = 0; t < n; t++) if (arr[i][k] + arr[t][j] == arr[i][j]) { flag = true; break; } if (flag) break; } if (!flag) { cout << "No" << endl; return 0; } } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long double PI = acos(-1); long long int Mod = 1000000007; long long int power(long long int b, long long int e, long long int m) { long long int res = 1; while (e) { if (e & 1) { res = (res * (b % m)) % m; e--; } else { b = ((b % m) * (b % m)) % m; e = e / 2; } } return res; } long long int power(long long int b, long long int e) { if (e == 0) return 1; if (e & 1) return b * power(b * b, e / 2); return power(b * b, e / 2); } bool isprime(long long int n) { if (n == 1) return 0; for (long long int i = 2; i < sqrt(n) + 2; i++) { if (n % i == 0 && (i != n)) { return 0; } } return 1; } void Its_time_to_go_in_loop() { long long int n; cin >> n; long long int a[n][n]; for (long long int i = 0; i < n; i++) for (long long int j = 0; j < n; j++) cin >> a[i][j]; for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < n; j++) { if (a[i][j] == 1) continue; long long int c = 0; for (long long int s = 0; s < n; s++) { for (long long int t = 0; t < n; t++) { if (a[i][j] == (a[i][s] + a[t][j])) { c = 1; break; } } if (c) break; } if (c) continue; else { cout << "No" << "\n"; return; } } } cout << "Yes" << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int t = 1, test = 1; while (t--) { Its_time_to_go_in_loop(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); int a[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", &a[i][j]); } } int t, p; int flag = 0; int pos = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { t = a[i][j]; flag = 0; pos = 0; if (t != 1) { for (int k = 0; k < n; k++) { p = a[k][j]; for (int l = 0; l < n; l++) { if ((t == a[i][l] + p) && k != i && l != j) pos = 1; } } if (!pos) { flag = 1; goto x; } } } } x: if (flag == 1) printf("NO\n"); else printf("YES\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX = 105; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<int>> m(n, vector<int>(n)); for (auto &x : m) for (auto &y : x) cin >> y; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) { bool ok = false; if (m[i][j] == 1) continue; for (int k = 0; k < n; ++k) for (int l = 0; l < n; ++l) ok |= m[i][k] + m[l][j] == m[i][j]; if (!ok) { cout << "No"; return 0; } } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; inline long long int read() { long long int x = 0; char ch = getchar(); for (; ch < '0' || '9' < ch; ch = getchar()) ; for (; '0' <= ch && ch <= '9'; ch = getchar()) x = (x << 3) + (x << 1) + ch - '0'; return x; } int n; int a[55][55]; bool solve(int x, int y) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[x][y] == a[x][i] + a[j][y]) return true; } } return false; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &a[i][j]); } } int flag = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[i][j] == 1) continue; if (solve(i, j)) continue; flag = false; break; } if (!flag) break; } if (flag) puts("Yes"); else puts("No"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, p, q; scanf("%d", &n); int A[51][51] = {0}; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { scanf("%d", &A[i][j]); } } int flag, ans = 1; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (A[i][j] == 1) continue; flag = 0; for (p = 1; p <= n; p++) { if (p == i) continue; for (q = 1; q <= n; q++) { if (q == j) continue; if ((A[p][j] + A[i][q]) == A[i][j]) { flag = 1; break; } } } if (flag == 0) { ans = 0; break; } } if (flag == 0) { ans = 0; break; } } if (ans == 0) printf("No"); else printf("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX_N = 200 + 9; int vec[MAX_N][MAX_N]; int main() { int N, M, T; while (~scanf("%d", &N)) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { scanf("%d", &vec[i][j]); } } int ans = 1; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (vec[i][j] != 1) { int res = 0; for (int k = 0; k < N; k++) { for (int p = 0; p < N; p++) { if (k != i && p != j && vec[k][j] + vec[i][p] == vec[i][j]) { res = 1; break; } } } if (res == 0) { ans = 0; break; } } } } if (ans == 0) printf("No\n"); else printf("Yes\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int N, sq[100][100]; bool checkNum(int row, int col) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i != row or j != col) if (sq[row][col] == sq[row][j] + sq[i][col]) { return true; } } } return false; } int main() { cin >> N; bool ans = true; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cin >> sq[i][j]; } } for (int i = 0; i < N and ans; i++) { for (int j = 0; j < N and ans; j++) { if (sq[i][j] != 1 and checkNum(i, j) == false) { ans = false; break; } } } ans == 1 ? cout << "Yes" : cout << "No"; }
#include <bits/stdc++.h> using namespace std; int n, i, j, t, s, b, a[51][51]; bool ans; int main() { cin >> n; for (i = 0; i < n; i++) for (j = 0; j < n; j++) cin >> a[i][j]; for (i = 0; i < n; i++) for (j = 0; j < n; j++) { if (a[i][j] != 1) { ans = false; for (t = 0; t < n; t++) for (s = 0; s < n; s++) if (a[i][j] == a[i][s] + a[t][j]) ans = true; if (!ans) { cout << "No"; return 0; } } } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; const int N = 55; int a[N][N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", &a[i][j]); } } int bad = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] == 1) continue; else { int ok = 0; for (int s = 0; s < n; s++) { if (s == i) continue; for (int t = 0; t < n; t++) { if (t == j) continue; if (a[i][t] + a[s][j] == a[i][j]) { ok = 1; break; } } if (ok) break; } if (ok) bad = 0; else { bad = 1; break; } } } if (bad) break; } if (!bad) puts("Yes"); else puts("No"); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 55; int g[maxn][maxn], n; bool check(int x, int y) { for (int i = 0; i < n; i++) { if (i == y) continue; for (int j = 0; j < n; j++) { if (j == x) continue; if (g[x][i] + g[j][y] == g[x][y]) return true; } } return false; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) scanf("%d", g[i] + j); } bool flag = true; for (int i = 0; i < n && flag; i++) { for (int j = 0; j < n && flag; j++) { if (g[i][j] > 1) flag = check(i, j); } } if (flag) printf("Yes\n"); else printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 55; int n; int a[N][N]; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cin >> a[i][j]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[i][j] == 1) continue; bool ok = false; for (int z = 1; z <= n; z++) { if (z == i) continue; for (int t = 1; t <= n; t++) { if (t == j) continue; if (a[i][t] + a[z][j] == a[i][j]) { ok = true; break; } } if (ok) break; } if (!ok) return cout << "No", 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int a[60][60]; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (a[i][j] != 1) { int flag = 0; for (int i1 = 1; i1 <= n; i1++) for (int j1 = 1; j1 <= n; j1++) if (a[i][j1] + a[i1][j] == a[i][j]) flag = 1; if (flag == 0) { printf("No\n"); return 0; } } printf("Yes\n"); return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> ii; pair<long long, long long> ll; const int N = 55; int a[N][N]; int n; bool get(int x, int y) { if (a[x][y] == 1) return true; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (a[x][y] == a[x][j] + a[i][y]) return true; } } return false; } int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { scanf("%d", &a[i][j]); } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (!get(i, j)) { puts("No"); return 0; } } } puts("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; int x, a[100][100], t; int main() { cin >> x; for (int i = 0; i < x; i++) { for (int j = 0; j < x; j++) { cin >> a[i][j]; } } for (int i = 0; i < x; i++) { for (int j = 0; j < x; j++) { if (a[i][j] == 1) continue; t = 0; for (int k = 0; k < x; k++) { for (int l = 0; l < x; l++) { if (a[i][k] + a[l][j] == a[i][j]) { t = 1; break; } } if (t == 1) break; } if (t == 0) { cout << "No"; return 0; } } } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; int n; int a[60][60]; bool is = true; int main() { scanf(" %d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf(" %d", &a[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] == 1) continue; bool c = false; for (int s = 0; s < n; s++) { for (int b = 0; b < n; b++) { if (a[s][j] + a[i][b] == a[i][j]) c = true; } } if (!c) is = false; } } if (is) printf("Yes\n"); else printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, k, l; string s = "YES"; cin >> n; int arr[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { cin >> arr[i][j]; } } int z = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (arr[i][j] != 1) { int a = 0; int p = arr[i][j]; for (k = 0; k < n; k++) { for (l = 0; l < n; l++) { if (arr[i][k] + arr[l][j] == p) { a = 1; } } } if (a == 0) { cout << "NO"; z = 1; break; } } } if (z == 1) break; } if (z == 0) cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int g[50][50]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> g[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (g[i][j] == 1) continue; bool fail = true; for (int k = 0; k < n; k++) { if (k == i) continue; for (int o = 0; o < n; o++) { if (o == j) continue; if (g[i][j] == g[i][o] + g[k][j]) fail = false; } } if (fail) { cout << "No"; return 0; } } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int N, M, K, T; int p[100][100]; int main() { scanf("%d", &N); for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) scanf("%d", &p[i][j]); bool ok = true; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { if (p[i][j] == 1) continue; bool found = false; for (int a = 1; a <= N; a++) for (int b = 1; b <= N; b++) { if (p[i][a] + p[b][j] == p[i][j]) found = true; } ok &= found; } } if (ok) printf("Yes"); else printf("No"); }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); long long int n = 0; cin >> n; long long int a[n][n]; long long int count = 0; for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < n; j++) { cin >> a[i][j]; if (a[i][j] != 1) count++; } } bool ans = true; for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < n; j++) { if (a[i][j] != 1) { for (long long int k = 0; k < n; k++) { for (long long int l = 0; l < n; l++) { if (a[k][j] + a[i][l] == a[i][j]) { ans = true; break; } else ans = false; } if (ans) break; } } if (!ans) break; } if (!ans) break; } if (ans) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1][n + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cin >> a[i][j]; } int cnt = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cnt = 0; if (a[i][j] != 1) { for (int t = 1; t <= n; t++) { for (int k = 1; k <= n; k++) { if (a[i][t] + a[k][j] == a[i][j]) cnt++; } } if (cnt == 0) { cout << "No"; return 0; } } } } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; const int MXN = 55; int a[MXN][MXN]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int aij; cin >> aij; a[i][j] = aij; } } bool pos = true; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int q = a[i][j]; if (q == 1) continue; bool posaij = false; for (int ii = 0; ii < n; ii++) { int b = a[ii][j]; for (int jj = 0; jj < n; jj++) { int c = a[i][jj]; if (q == c + b) { posaij = true; break; } } if (posaij) break; } if (!posaij) pos = false; } } if (pos) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<vector<int>> v(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> v[i][j]; } } int flag = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (v[i][j] != 1) { flag = 0; for (int k = 0; k < n; k++) { for (int l = 0; l < n; l++) { if (k != i && j != l && v[k][j] + v[i][l] == v[i][j]) flag = 1; } } if (flag == 0) { cout << "No"; return 0; } } } } cout << "Yes"; }
#include <bits/stdc++.h> int map[55][55]; int n; void ans(void) { int i, j, s, t; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { int flag = 0; if (map[i][j] == 1) continue; for (s = 1; s <= n; s++) { for (t = 1; t <= n; t++) { if (map[i][j] == map[i][s] + map[t][j]) flag = 1; } } if (flag == 0) { printf("No"); return; } } } printf("Yes"); return; } int main(void) { int i, j, s, t; scanf("%d", &n); for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) scanf("%d", &map[i][j]); } ans(); }
#include <bits/stdc++.h> using namespace std; bool good(const vector<vector<int>>& lab); int main() { int size; while (cin >> size) { vector<vector<int>> lab(size, vector<int>(size)); for (int r = 0; r < size; r++) for (int c = 0; c < size; c++) cin >> lab[r][c]; if (good(lab)) cout << "Yes\n"; else cout << "No\n"; } } bool good(const vector<vector<int>>& lab, int r, int c) { for (int rr = 0; rr < lab.size(); rr++) for (int cc = 0; cc < lab[rr].size(); cc++) if (lab[r][c] == lab[r][cc] + lab[rr][c]) return true; return false; } bool good(const vector<vector<int>>& lab) { for (int r = 0; r < lab.size(); r++) for (int c = 0; c < lab[r].size(); c++) if (lab[r][c] != 1 && !good(lab, r, c)) { return false; } return true; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t, n, m, x, i, j, k, l, ans; cin >> n; long long a[n][n]; for (long long i = 0; i < n; i++) for (long long j = 0; j < n; j++) cin >> a[i][j]; bool ok; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { if (a[i][j] != 1) { ok = 1; for (long long k = 0; k < n; k++) { for (long long l = 0; l < n; l++) { if (a[i][k] + a[l][j] == a[i][j]) { ok = 0; break; } } if (!ok) break; } if (ok) { cout << "No" << '\n'; return 0; } } } } cout << "Yes" << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, x; long long int n, r, c; cin >> n; long long int a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) cin >> a[i][j]; } bool f; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { f = false; if (a[i][j] == 1) { f = true; continue; } else { x = a[i][j]; for (r = 0; r < n; r++) { for (c = 0; c < n; c++) { if (a[i][r] + a[c][j] == x) { f = true; break; } } if (f) break; } if (!f) { cout << "No"; return 0; } } } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[55][55]; int check(int r, int c) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i != r && j != c && a[i][c] + a[r][j] == a[r][c]) return 1; } } return 0; } int main() { cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> a[i][j]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[i][j] != 1 && !check(i, j)) { cout << "No" << endl; return 0; } } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int min(int x, int y, int z) { return min(min(x, y), z); } void Rose() { int n; cin >> n; int a[n][n]; bool ok = true; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (a[i][j] == 1) { continue; } bool done = false; for (int s = 0; s < n; ++s) { for (int t = 0; t < n; ++t) { if (a[i][s] + a[t][j] == a[i][j]) { done = true; } } } if (!done) { ok = false; } } } cout << (ok ? "Yes\n" : "No\n"); } int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cin.exceptions(ios::badbit | ios::failbit); Rose(); return 0; }
#include <bits/stdc++.h> using namespace std; clock_t start; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); template <typename T> void _F(const char *name, T arg1) { cerr << name << " = " << arg1 << endl; } template <typename T, typename... Args> void _F(const char *names, T arg1, Args... args) { const char *name = strchr(names, ','); cerr.write(names, name - names) << " = " << arg1 << endl; _F(name + 2, args...); } template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &q) { in >> q.first >> q.second; return in; } template <typename T1, typename T2> ostream &operator<<(ostream &out, pair<T1, T2> &q) { out << q.first << " " << q.second; return out; } template <typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2) { return {p1.first + p2.first, p1.second + p2.second}; } template <typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2) { return {p1.first - p2.first, p1.second - p2.second}; } void solve() { long long n; cin >> n; long long a[n][n]; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) cin >> a[i][j]; } for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { bool f = 0; for (long long ii = 0; ii < n; ii++) { for (long long jj = 0; jj < n; jj++) { if (a[i][j] == a[i][ii] + a[jj][j]) f = 1; } } if ((!f) && a[i][j] != 1) { cout << "NO" << endl; return; } } } cout << "YES" << endl; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t = 1; start = clock(); cout << fixed << setprecision(20); for (long long i = 1; i <= t; ++i) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<int>> v; for (int i = 0; i < n; ++i) { vector<int> temp; for (int j = 0; j < n; ++j) { int x; cin >> x; temp.push_back(x); } v.push_back(temp); } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (v[i][j] == 1) continue; int flag = 0; for (int p = 0; p < n; ++p) { for (int q = 0; q < n; ++q) { if (v[i][p] + v[q][j] == v[i][j]) flag = 1; } } if (!flag) { cout << "No"; return 0; } } } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; struct noone { int row, column; }; int main() { int n, i, j; scanf("%d", &n); vector<noone> numbers; vector<int> checker(100001, 0); vector<vector<int> > column(n + 1, checker); vector<vector<int> > matrix(n + 1); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { int k; scanf("%d", &k); matrix[i].push_back(k); column[j][k] = 1; if (k != 1) { noone tmp; tmp.row = i; tmp.column = j; numbers.push_back(tmp); } } } bool chk = 1; for (i = 0; i < numbers.size(); i++) { int currow = numbers[i].row, curcolumn = numbers[i].column; int target = matrix[currow][curcolumn]; chk = 0; for (j = 0; j < matrix[currow].size(); j++) { if (j == curcolumn) { continue; } if (target >= matrix[currow][j]) { if (column[curcolumn][target - matrix[currow][j]]) { chk = 1; break; } } } if (!chk) { break; } } if (chk) { cout << "Yes" << endl; } else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a[51][51]; int b[52][2]; int n, i, j, x, y; bool flag = true, f; memset(a, 0, sizeof(a)); cin >> n; for (i = 0; i < n; i++) for (j = 0; j < n; j++) cin >> a[i][j]; for (i = 0; i < n && (flag); i++) for (j = 0; j < n; j++) { if (a[i][j] != 1) { f = false; x = 0; y = 0; for (int k = 0; k < n; k++) { if (a[i][k] < a[i][j]) b[x++][0] = a[i][k]; if (a[k][j] < a[i][j]) b[y++][1] = a[k][j]; } for (int k = 0; k < x && (f == false); k++) for (int m = 0; m < y; m++) { if (b[k][0] + b[m][1] == a[i][j]) { f = true; break; } } if (f == false) { flag = false; break; } } } if (flag) { cout << "YES"; } else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, i, j, v[55][55], stop; int main() { cin >> n; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) cin >> v[i][j]; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (v[i][j] != 1) { stop = 0; for (a = 1; a <= n; a++) { for (b = 1; b <= n; b++) { if (v[i][a] + v[b][j] == v[i][j]) stop = 1; } } if (stop == 0) { cout << "No"; return 0; } } } } cout << "Yes"; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int a[n][n], x; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> a[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { long long int flag = 0; if (a[i][j] != 1) x = a[i][j]; for (int k = 0; k < n; k++) { for (int m = 0; m < n; m++) { if (x == a[i][m] + a[k][j]) { flag = 1; } } } if (flag == 0 && a[i][j] != 1) { cout << "No" << "\n"; return 0; } } } cout << "Yes" << "\n"; }
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, i, j, c, e, f, g, h, p = 0, s, t, w; vector<long long int> v; vector<long long int> v1; cin >> n; long long int a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) cin >> a[i][j]; } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (a[i][j] != 1) { c = a[i][j]; p = 0; for (e = j - 1; e >= 0; e--) { v.push_back(a[i][e]); } for (e = j + 1; e < n; e++) { v.push_back(a[i][e]); } for (f = i + 1; f < n; f++) { v1.push_back(a[f][j]); } for (f = i - 1; f >= 0; f--) { v1.push_back(a[f][j]); } for (g = 0; g < v.size(); g++) { for (h = 0; h < v1.size(); h++) { s = v[g]; t = v1[h]; if (s + t == c) { p++; break; } } if (p > 0) break; } if (p == 0) { cout << "No" << endl; return; } v.clear(); v1.clear(); } } } cout << "Yes" << endl; return; } int main() { solve(); }
#include <bits/stdc++.h> using namespace std; int mmp[100][100]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cin >> mmp[i][j]; } int flag = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (mmp[i][j] != 1) { int tmp = 0; for (int l = 1; l <= n; l++) { for (int g = 1; g <= n; g++) { if (mmp[i][l] + mmp[g][j] == mmp[i][j]) { tmp = 1; break; } } } if (!tmp) { flag = 1; break; } } } } if (flag) cout << "No" << endl; else cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int num[51][51]; int n; bool judge() { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (num[i][j] != 1) { int flag = 0; for (int k = 0; k < n; k++) { if (k != j) for (int l = 0; l < n; l++) { if (l != i) { if (num[i][k] + num[l][j] == num[i][j]) { flag = 1; goto here; } } } } here: if (flag == 0) return false; } } } return true; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", &num[i][j]); } } printf("%s\n", judge() ? "Yes" : "No"); }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, j, k, l, a[100][100], c = 0; cin >> n; for (i = 0; i < n; i++) for (j = 0; j < n; j++) { cin >> a[i][j]; if (a[i][j] != 1) c++; } for (i = 0; i < n; i++) for (j = 0; j < n; j++) { if (a[i][j] != '1') { for (k = 0; k < n; k++) { for (l = 0; l < n; l++) if ((a[i][k] + a[l][j]) == a[i][j]) break; if (l != n) break; } if (k != n) c--; } } if (c == 0) cout << "Yes"; else cout << "No"; return 0; }
#include <bits/stdc++.h> int main() { int n, i, j; scanf("%d", &n); int a[n][n]; int count = 0, x = 0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%d", &a[i][j]); if (a[i][j] != 1) x++; } } int k, m; int aux[n][2], check = 0, sum; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { check = 0; k = i; m = j; for (k = 0; k < n; k++) { aux[k][0] = a[k][j]; } for (k = 0; k < n; k++) { aux[k][1] = a[i][k]; } if (a[i][j] != 1) { for (k = 0; k < n; k++) { for (m = 0; m < n; m++) { sum = aux[k][0] + aux[m][1]; if (sum == a[i][j]) check = 1; } } if (check == 1) count++; else { printf("NO\n"); return 0; } } } } if (count == x) printf("YES\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, **x, check; cin >> n; x = new int *[n]; for (int i = 0; i < n; i++) { x[i] = new int[n]; for (int j = 0; j < n; j++) cin >> x[i][j]; } for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (x[i][j] != 1) { check = 0; for (int ii = 0; ii < n; ii++) for (int jj = 0; jj < n; jj++) if (x[i][ii] + x[jj][j] == x[i][j]) check = 1; if (!check) return cout << "NO", 0; } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const long long INF = 1000000000000030200; const int A = 1234567; map<int, bool> check[3000]; int main() { int arr[51][51]; int a; cin >> a; for (int i = 0; i < a; i++) for (int x = 0; x < a; x++) cin >> arr[i][x]; int c = 0; bool end = false; for (int i = 0; i < a; i++) for (int x = 0; x < a; x++) { if (arr[i][x] != 1) { for (int f = 0; f < a; f++) { if (f != x) check[c][arr[i][f]] = true; } for (int j = 0; j < a; j++) { if (j != i) { if (check[c][arr[i][x] - arr[j][x]]) { end = true; } } } if (!end) { cout << "No"; return 0; } end = false; } c++; } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x7fffffff; const int inf = 0x3f3f3f3f; const int maxn = 200005; const int N = 105; inline void read(long long &x) { long long f = 1; x = 0; char s = getchar(); while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); } while (s >= '0' && s <= '9') { x = x * 10 + s - '0'; s = getchar(); } x *= f; } long long n, a[N][N]; int main() { read(n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { read(a[i][j]); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { long long x = a[i][j]; if (x == 1) continue; bool flag = 0; for (int k = 1; k <= n; k++) { for (int l = 1; l <= n; l++) { if (x == a[i][k] + a[l][j]) flag = 1; } } if (!flag) { cout << "NO" << endl; return 0; } } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; vector<long long> prime; bool primes[1234567 + 1]; long long cntp[1234567 + 1]; void sv() { for (long long i = 2; i <= 1234567; i++) primes[i] = true; for (long long i = 2; i <= 1234567; i++) { if (primes[i]) { cntp[i] = 1; for (long long j = 2 * i; j <= 1234567; j += i) { primes[j] = false; cntp[j]++; } prime.push_back(i); } } } long long fexp(long long base, long long exp) { long long res = 1; while (exp > 0) { if (exp % 2 == 1) res = (res % 1000000007 * base % 1000000007) % 1000000007; base = (base % 1000000007 * base % 1000000007) % 1000000007; exp /= 2; } return res % 1000000007; } long long sod(long long num) { long long res = 0; while (num) { res += num % 10; num /= 10; } return res; } void nxp(string s) { do { cout << s << "\n"; } while (next_permutation(s.begin(), s.end())); } long long table[1234567 + 1]; void coinways(long long n) { long long coins[] = {1, 2, 3, 4}; table[0] = 1; for (long long i = 0; i < (sizeof(coins) / sizeof(coins[0])); i++) { for (long long j = coins[i]; j <= 1234567; j++) { table[j] += table[j - coins[i]]; } } cout << table[n]; } void coinmin(long long n) { long long coins[] = {1, 2, 3, 4}; table[0] = 0; for (long long i = (1); i < (1 + 1234567); ++i) table[i] = INT_MAX; for (long long i = 1; i <= 1234567; i++) { for (long long j = 0; j < (sizeof(coins) / sizeof(coins[0])); j++) { if (i - coins[j] > 0) { long long res = table[i - coins[j]]; if (res != INT_MAX && res + 1 < table[i]) { table[i] = res + 1; } } } } cout << table[n]; } int main() { ios_base::sync_with_stdio(false), cin.tie(0); sv(); long long(n); cin >> n; long long a[n][n]; for (long long i = 0; i < (n); ++i) { for (long long j = 0; j < (n); ++j) { cin >> a[i][j]; } } if (n < 2) { if (a[0][0] != 1) cout << "No"; else cout << "Yes"; return 0; } long long flag = 0; for (long long i = 0; i < (n); ++i) { for (long long j = 0; j < (n); ++j) { if (a[i][j] == 1) continue; for (long long k = 0; k < (n); ++k) { if (k == j) continue; long long sum = a[i][k]; for (long long h = 0; h < (n); ++h) { if (h == i) continue; if (sum + a[h][j] == a[i][j]) { flag = 1; break; } else flag = 2; } if (flag == 1) break; } if (flag == 2) { cout << "No"; return 0; } flag = 0; } } cout << "Yes"; return 0; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, k, sum = 0, a[100][100], b[100005], ans = 0; cin >> n; for (int i = 0; i < int(n); ++i) for (int j = 0; j < int(n); ++j) cin >> a[i][j]; for (int i = 0; i < int(n); ++i) for (int j = 0; j < int(n); ++j) { if (a[i][j] != 1) { int flag = 0; for (int k = 0; k < int(n); ++k) { for (int l = 0; l < int(n); ++l) if (a[k][j] + a[i][l] == a[i][j]) { flag = 1; break; } if (flag) break; } if (!flag) { cout << "NO"; return 0; } } } cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> a[i][j]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int f = 0; if (a[i][j] != 1) { f = 1; for (int k = 0; k < n; k++) { if (k == j) continue; int fl = 0; for (int l = 0; l < n; l++) { int sum = a[i][k]; if (l == i) continue; sum += a[l][j]; if (sum == a[i][j]) { fl = 1; f = 2; break; } } if (fl) { fl = 0; break; } } } if (f == 1) { cout << "No\n"; return 0; } } } cout << "Yes\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int v[50][50], n; bool func(int i, int j) { int x, y; for (x = 0; x < n; x++) { for (y = 0; y < n; y++) { if (x != i && y != j) { if (v[i][y] + v[x][j] == v[i][j]) { return false; } } } } return true; } int main() { #pragma warning(disable : 4996); int m, i, j, s = 0, y, x = 0; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%d", &v[i][j]); } } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (v[i][j] != 1) { if (func(i, j)) { printf("No"); return 0; } } } } printf("Yes"); return 0; }
#include <bits/stdc++.h> int m; void merge(long long int arr[], long long int l, long long int m, long long int r) { long long int i, j, k; long long int n1 = m - l + 1; long long int n2 = r - m; long long int L[n1], R[n2]; for (i = 0; i < n1; i++) L[i] = arr[l + i]; for (j = 0; j < n2; j++) R[j] = arr[m + 1 + j]; i = 0; j = 0; k = l; while (i < n1 && j < n2) { if (L[i] <= R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } k++; } while (i < n1) { arr[k] = L[i]; i++; k++; } while (j < n2) { arr[k] = R[j]; j++; k++; } } void mergeSort(long long int arr[], long long int l, long long int r) { if (l < r) { int m = l + (r - l) / 2; mergeSort(arr, l, m); mergeSort(arr, m + 1, r); merge(arr, l, m, r); } } int main() { int n, i, j, x, y; scanf("%d", &n); m = n; int arr[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%d", &arr[i][j]); } } for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (arr[i][j] > 1) { m = 0; for (x = 0; x < n; x++) { for (y = 0; y < n; y++) { if (arr[i][j] == arr[x][j] + arr[i][y]) { m = 1; break; } } if (m == 1) { break; } } if (m == 0) { 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); int ans = 0; int n; cin >> n; int ar[100][100]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> ar[i][j]; } } bool b = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int h = 0; h < n; h++) { for (int k = 0; k < n; k++) { if (ar[i][j] != 1) if ((ar[i][k] + ar[h][j]) == ar[i][j]) { b = 1; } } } if (!b && ar[i][j] != 1) { cout << "no" << endl; return 0; } b = 0; } } cout << "yes" << endl; return 0; }
#include <bits/stdc++.h> const long long INF = LLONG_MAX / 2; const long long N = 2e5 + 1; using namespace std; long long fact[100005], ifact[100005]; void pre(); long long ncr(long long, long long); long long pow1(long long n, long long p) { if (p == 0) return 1; long long x = pow1(n, p / 2); x = (x * x) % 1000000007; if (p % 2 == 0) return x; else return (x * n) % 1000000007; } long long binarySearch(long long arr[], long long l, long long r, long long x) { if (r >= l) { long long mid = l + (r - l) / 2; if (arr[mid] == x) return mid; if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); return binarySearch(arr, mid + 1, r, x); } return -1; } long long gcd(long long a, long long b, long long &x, long long &y) { if (a == 0) { x = 0; y = 1; return b; } long long x1, y1; long long d = gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return d; } bool find_any_solution(long long a, long long b, long long c, long long &x0, long long &y0, long long &g) { g = gcd(llabs(a), llabs(b), x0, y0); if (c % g) { return false; } x0 *= c / g; y0 *= c / g; if (a < 0) x0 = -x0; if (b < 0) y0 = -y0; return true; } void shift_solution(long long &x, long long &y, long long a, long long b, long long cnt) { x += cnt * b; y -= cnt * a; } long long find_all_solutions(long long a, long long b, long long c, long long minx, long long maxx, long long miny, long long maxy) { long long x, y, g; if (!find_any_solution(a, b, c, x, y, g)) return 0; a /= g; b /= g; long long sign_a = a > 0 ? +1 : -1; long long sign_b = b > 0 ? +1 : -1; shift_solution(x, y, a, b, (minx - x) / b); if (x < minx) shift_solution(x, y, a, b, sign_b); if (x > maxx) return 0; long long lx1 = x; shift_solution(x, y, a, b, (maxx - x) / b); if (x > maxx) shift_solution(x, y, a, b, -sign_b); long long rx1 = x; shift_solution(x, y, a, b, -(miny - y) / a); if (y < miny) shift_solution(x, y, a, b, -sign_a); if (y > maxy) return 0; long long lx2 = x; shift_solution(x, y, a, b, -(maxy - y) / a); if (y > maxy) shift_solution(x, y, a, b, sign_a); long long rx2 = x; if (lx2 > rx2) swap(lx2, rx2); long long lx = max(lx1, lx2); long long rx = min(rx1, rx2); if (lx > rx) return 0; return (rx - lx) / llabs(b) + 1; } bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } bool compare(const pair<long long, long long> &p1, const pair<long long, long long> &p2) { if (p1.first < p2.first) return true; if (p1.first == p2.first) return p1.second < p2.second; return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t; t = 1; while (t--) { long long n; std::cin >> n; long long a[n][n], x = 0, y = 0; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) std::cin >> a[i][j]; } for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { if (a[i][j] == 1) continue; y = 0; for (long long k = 0; k < n; k++) { for (long long l = 0; l < n; l++) { if (l == j || k == i) continue; else { if (a[i][l] + a[k][j] == a[i][j]) { y = 1; break; } } if (y == 1) break; } if (y == 1) break; } if (y == 0) x = 1; if (x == 1) break; } if (x == 1) break; } if (x == 0) cout << "Yes\n"; else cout << "No\n"; } } void pre() { long long n = 100000; fact[0] = fact[1] = 1; for (long long i = 2; i <= n; i++) fact[i] = (fact[i - 1] * i) % 1000000007; ifact[n] = pow1(fact[n], 1000000007 - 2); for (long long i = n - 1; i >= 0; i--) { ifact[i] = (ifact[i + 1] * (i + 1)) % 1000000007; } } long long ncr(long long n, long long r) { long long res = (fact[n] * ifact[r]) % 1000000007; res = (res * ifact[n - r]) % 1000000007; return res; }
#include <bits/stdc++.h> using namespace std; long long A[100][100]; int main() { long long(n); scanf("%lld", &n); for (long long i = 0; i < (n); ++i) for (long long j = 0; j < (n); ++j) scanf("%lld", &(A[i][j])); for (long long i = 0; i < (n); ++i) for (long long j = 0; j < (n); ++j) { if (A[i][j] != 1) { set<long long> SS; bool ok = 0; for (long long jj = 0; jj < (n); ++jj) SS.insert(A[i][jj]); for (long long ii = 0; ii < (n); ++ii) if (SS.count(A[i][j] - A[ii][j])) ok = 1; if (!ok) return 0 * puts("No"); } } puts("Yes"); }
#include <bits/stdc++.h> using namespace std; int main() { int n, a[55][55]; while (cin >> n) { int maxn = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> a[i][j]; if (a[i][j] > maxn) { maxn = a[i][j]; } } } if (maxn == 1) { cout << "Yes" << endl; continue; } int tf = 0; for (int ii = 1; ii <= n; ii++) { for (int jj = 1; jj <= n; jj++) { int x = 0; if (a[ii][jj] > 1) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (a[ii][j] + a[i][jj] == a[ii][jj]) { x = 1; break; } } if (x == 1) { break; } } } if (x == 0 && a[ii][jj] > 1) { tf = 1; break; } } } if (tf == 1) { cout << "No" << endl; } else { cout << "Yes" << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int n; int c[55][55]; int flag; int not_ok(int x, int y) { int flag2 = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (c[x][i] + c[j][y] == c[x][y]) { flag2 = 1; } } } if (flag2 == 1) return 0; else return 1; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &c[i][j]); } } flag = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (c[i][j] != 1 && not_ok(i, j)) flag = 0; } } if (flag == 1) printf("Yes"); else printf("No"); return 0; }