text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long q = 1, i, j, test;
cin >> q;
for (test = 1; test < (q + 1); test++) {
long long n;
cin >> n;
char a[n][n];
for (i = 0; i < (n); i++)
for (j = 0; j < (n); j++) cin >> a[i][j];
vector<pair<int, int> > v;
int ans = 0;
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
string a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
long long c = 0;
long long p1 = a[0][1] - '0', p2 = a[1][0] - '0';
long long q1 = a[n - 1][n - 2] - '0', q2... |
#include <bits/stdc++.h>
char s[210][210];
int T, n;
int ansx[3], ansy[3], tot;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
tot = 0;
for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
if (s[1][2] == s[2][1]) {
if (s[1][2] == s[n - 1][n]) ansx[++tot] = n - 1, ansy[tot] = n;
... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200 + 5;
int t, n;
char arr[N][N];
vector<pair<int, int>> ans;
void solve() {
ans.clear();
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> arr[i][j];
}
}
int zerocnt = 0, onecnt = 0, zerocnt2 = 0, onecnt2 ... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
long long modPow(long long a, long long b);
long long modInv(long long a);
void solve() {
long long n;
cin >> n;
char a[n][n];
for (long long i = 0; i < n; i++)
fo... |
#include <bits/stdc++.h>
namespace FastIO {
bool IOerror = 0;
inline char nc() {
static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;
if (p1 == pend) {
p1 = buf;
pend = buf + fread(buf, 1, 100000, stdin);
if (pend == p1) {
IOerror = 1;
return -1;
}
}
return *p1++;
}
inl... |
#include <bits/stdc++.h>
using namespace std;
const int maax = 300001;
const long long mod = 998244353;
long long prime[maax];
long long fact[maax];
long long inv[maax];
long long nCr(long long n, long long r) {
return (((fact[n] * inv[r]) % mod) * inv[n - r]) % mod;
}
void make() {
prime[1] = 1;
for (long long i... |
#include <bits/stdc++.h>
using namespace std;
const bool multi_test = true;
bool solve() {
int n;
cin >> n;
vector<string> t(n);
for (int(i) = 0; (i) < (n); (i)++) cin >> t[i];
char a, b, c, d;
a = t[0][1];
b = t[1][0];
c = t[n - 1][n - 2];
d = t[n - 2][n - 1];
if (a == b) {
if (c == d) {
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
string s[n];
long long int cntU = 0, cntD = 0;
for (long long int i = 0; i < n; i++) {
cin >> s[i];
}
if (s[0][1] == '0' && s[1][0] == '0') {
if (s... |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long MAX = 100100;
void pre() {}
void solve() {
long long n;
cin >> n;
vector<string> v(n);
for (long long i = 0; i < n; ++i) cin >> v[i];
vector<pair<long long, long long> > rm;
long long up ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int dim;
cin >> dim;
vector<vector<int> > vec;
vector<int> load;
string a;
for (int i = 0; i < dim; i++) {
cin >> a;
for (int j = 0; j < dim; j++) {
load.push_back(a[j] - 48);
... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
char a[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<string> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
int up = (v[0][1] - 48) + (v[1][0] - 48);
int ... |
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using PLL = pair<LL, LL>;
using UI = unsigned int;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int N = 210;
int T, n;
char... |
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000005;
const long long mod = 1e18;
const long long N = 1e5 + 5;
long long T = 0;
const string alphabet = {"abcdefghijklmnopqrstuvwxyz"};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void solve() {
long long n = 0, i, a,... |
#include <bits/stdc++.h>
using namespace std;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main() {
fast();
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
char arr[n][n];
long long i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
... |
#include <bits/stdc++.h>
using namespace std;
inline void sol() {
long long n;
cin >> n;
vector<vector<char>> grid(n, vector<char>(n));
for (auto &i : grid)
for (auto &j : i) cin >> j;
long long s1 = grid[0][1] + grid[1][0] - 2 * '0';
long long s2 = grid[n - 1][n - 2] + grid[n - 2][n - 1] - 2 * '0';
i... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<string> graph(n);
for (auto &i : graph) cin >> i;
int a = graph[0][1], b = graph[1][0], c = graph[n - 2][n - 1],
d = graph[n - 1][n - 2]... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<vector<char> > mat;
for (int i = 0; i < n; i++) {
vector<char> v(n);
for (int j = 0; j < n; j++) cin >> v[j];
mat.push_back(v);
}
bool c1 = (mat[0][2] == mat[... |
#include <bits/stdc++.h>
const int INF = 1 << 29;
const double PI = acos(-1.0);
using namespace std;
void solve() {
int n;
cin >> n;
vector<string> v(n);
vector<pair<int, int>> ans;
for (string &it : v) cin >> it;
char a = v[0][1], b = v[1][0], c = v[n - 1][n - 2], d = v[n - 2][n - 1];
if (a == '1' && b =... |
#include <bits/stdc++.h>
using namespace std;
const int N = 210;
char a[N][N];
int n;
void pp(void) {
if (a[1][2] == '1')
cout << 1 << endl << ' ' << 1 << ' ' << 2 << endl;
else
cout << 1 << endl << ' ' << 2 << ' ' << 1 << endl;
}
void pp1(void) {
if (a[n - 1][n] == '0')
cout << 1 << endl << ' ' << n ... |
#include <bits/stdc++.h>
const unsigned long long int M = 1000000007;
using namespace std;
long long power(long long x, long long y) {
long long res = 1;
while (y > 0) {
if (y & 1) res = x * res;
y = y >> 1;
x = x * x;
}
return res;
}
long long power(long long x, long long y, long long mod) {
long... |
#include <bits/stdc++.h>
using namespace std;
const int N = 212;
char s[N];
void print(vector<pair<int, int>> &resp) {
printf("%d\n", (int)resp.size());
for (auto a : resp) {
printf("%d %d\n", a.first, a.second);
}
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
... |
#include <bits/stdc++.h>
using namespace std;
namespace chino {
const int maxn = 0x3f3f3f3f;
const int inf = 0x7fffffff;
} // namespace chino
inline int read() {
char ch;
int f = 1, x = 0;
do {
ch = getchar();
if (ch == '-') f = -1;
} while (!isdigit(ch));
do {
x = x * 10 + ch - '0';
ch = get... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
char a[n + 1][n + 1];
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) cin >> a[i][j];
int a12 = a[1][2] - ... |
#include <bits/stdc++.h>
using namespace std;
void fastio() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
void one();
int main() {
fastio();
int t = 1;
cin >> t;
for (int i = 0; i < t; ++i) {
one();
}
return 0;
}
void one() {
int n;
cin >> n;
vector<string> s;
for (int i = 0; i... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<vector<int> > v;
char a[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
int c = 0;
int zeroc = 0;
int onec = 0;
if (a[0][1] == '0')
zeroc++;
else
onec++... |
#include <bits/stdc++.h>
using namespace std;
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 ui... |
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.0);
template <typename T>
inline T sq(T a) {
return a * a;
}
template <typename T1, typename T2>
inline pair<T1, T2> mp(T1 a, T2 b) {
return make_pair(a, b);
}
template <typename T1, typename T2>
inline T1 safeMod(T1 a,... |
#include <bits/stdc++.h>
using namespace std;
int read() {
int re = 0;
char c = getchar();
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') {
re = re * 10 + c - '0';
c = getchar();
}
return re;
}
int t;
string mat[300];
int vis[300][300], chg[300][300];
int main() {
cin >> t;... |
#include <bits/stdc++.h>
using namespace std;
void vin(vector<int>& v) {
int i, p;
int n = (int)v.size();
for (i = 0; i < n; i++) {
scanf("%d", &v[i]);
}
}
void vin(vector<long long>& v) {
long long i, p;
int n = v.size();
for (i = 0; i < n; i++) {
scanf("%lld", &v[i]);
}
}
void vout(const vecto... |
#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
long long countdigit(long long n) {
long long x = n, c = 0;
while (x != 0) {
x = x / 10;
c++;
}
return c;
}
void solve() {
long long n;
cin >> n;
strin... |
#include <bits/stdc++.h>
const long long M = 1e7 + 7;
const double pi = 3.14159265358979323846;
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long a, b, c, d;
for (long lo... |
#include <bits/stdc++.h>
using namespace std;
const int M = INT_MAX;
const int N = INT_MIN;
using namespace std;
int main() {
int t = 0;
cin >> t;
while (t--) {
int n, c = 0;
cin >> n;
char d[n + 1][n + 1];
vector<pair<int, int>> vect;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= ... |
#include <bits/stdc++.h>
using namespace std;
const int M = (int)2e2;
const int N = (int)1e5;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const long long mod = (long long)1e9 + 7;
char s[M + 5][M + 5];
void work() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
char ch[4];... |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
bool isKthBitSet(long long n, long long k) {
if (n & (1 << (k - 1)))
return true;
else
return fals... |
#include <bits/stdc++.h>
using namespace std;
long long int div_floor(const long long int &a, const long long int &b) {
return a / b - (((a ^ b) < 0) and a % b);
}
long long int div_ceil(const long long int &a, const long long int &b) {
return a / b + (((a ^ b) >= 0) and a % b);
}
void solve() {
int n;
cin >> n... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long MAX = 1e18 + 1;
const double pi = 3.1415926535897932384626433832;
const long long M = 1e9 + 7;
long long bis(long long a[], long long l, long long r, long long x) {
while (l <= r) {
long long m = l + (r - l) / 2;
if (a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
char g[n][n], a[4];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) cin >> g[i][j];
}
a[0] = g[0][1];
a[1] = g[1][0];
a[2] = g[n - 1][n - 2];
a[3] = g[n - ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
string s[n];
for (int i = 0; i < n; i++) {
cin >> s[i];
}
if (s[0][1] == s[1][0]) {
if (s[n - 1][n - 2] == s[n - 2][n - 1] && s[n - 1][n - 2] != s[0][1]) {
c... |
#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int SIZE = (1 << 20) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = obuf + SIZE - 1;
char _st[55];
int _qr = 0;
inline char gc() {
return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
(iS == iT ? EOF : *iS++) : *... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s[n];
for (int i = 0; i < n; i++) {
cin >> s[i];
}
if (s[1][0] == s[0][1]) {
if (s[n - 1][n - 2] == s[n - 2][n - 1] && s[n - 1][n - 2] != s[0][1]) {
cout <<... |
#include <bits/stdc++.h>
using namespace std;
void input() {
freopen("input.txt", "r", stdin);
freopen("dekho.txt", "w", stdout);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
char a[n][n];
for (long long i = (0); i < (n); i++)
... |
#include <bits/stdc++.h>
int main() {
int t;
scanf("%d", &t);
int x[3];
int y[3];
int num;
char str[205][205];
while (t--) {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%s", &str[i][1]);
num = 0;
if (str[2][1] == str[1][2]) {
if (str[n - 1][n] == str[2][1]) {
... |
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(nam... |
#include <bits/stdc++.h>
const unsigned int MOD = 1000000007;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for (int tt = 0; tt < t; tt++) {
int n;
cin >> n;
string s[n];
for (int i = 0; i < n; i++) {
cin >> s[i];
}
char c = s... |
#include <bits/stdc++.h>
using namespace std;
long long mod(long long x) {
return (((x % 1000000007) + 1000000007) % 1000000007);
}
long long mul(long long x, long long y) { return mod(mod(x) * mod(y)); }
long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long modpow(long long x, long long ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10;
char str[N][N];
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) scanf("%s", str[i]);
int tou1 = 0, wei1 = 0;
if (str[0][1] == '1') tou1++;
if (str[1][0] == '1') tou... |
#include <bits/stdc++.h>
using namespace std;
const int nax = 203;
char a[nax][nax];
void run_case() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
cin >> a[i][j];
}
}
vector<pair<int, int>> ans;
if (a[n - 1][n - 2] != '1') {
ans.push_back({n, n - 1});
}
... |
#include <bits/stdc++.h>
using namespace std;
char s[400][400];
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
int one = 0, zero = 0;
if (s[1][2] == '1')
one++;
else
zero++;
if (s[2][1] == '1')
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
short l = 0;
bool b = 0;
vector<vector<short>> v(3);
for (int i = 0; i < 3; i++)
for (int j = 0; j < 2; j++) {
cin >> l;
v[i].push_back(l);
}
short x = (v[2][1] - v[0][1] + v[1][1]) / 2;
short a[4];
a[0] = v[0][0] - x;
a[1] =... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
if (i + j == r1 && i != j) {
for (int k = 1; k < 10; k++) {
if (i + k == c1 && k + j == d2 && ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, x, y, z, w;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (x = 1; x < 10; ++x) {
y = r1 - x;
z = c1 - x;
w = d1 - x;
if (x != y && x != z && x != w && y != z && y != w && z != w && y < 10 &&
y > 0 && z > ... |
#include <bits/stdc++.h>
using namespace std;
vector<int> solve(int r1, int r2, int c1, int c2, int d1, int d2) {
for (int a = 1; a <= 9; ++a)
for (int b = 1; b <= 9; ++b)
for (int c = 1; c <= 9; ++c)
for (int d = 1; d <= 9; ++d) {
if (a == b or a == c or a == d or b == c or b == d or c ==... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(nullptr), cout.tie(nullptr);
int r1, r2, c1, c2, d1, d2, s1 = 0, s2 = 0, s3 = 0, s4 = 0, s5 = 0, s6 = 0,
i = 0, j = 0, l = 0, k = 0, a = 0, b = 0, c = 0,
d = 0;
c... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
int a, b, c, d;
scanf("%d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
for (int a = 1; a <= 9; a++)
for (int b = 1; b <= 9; b++) {
if (a == b) continue;
for (int c = 1; c <= 9; c++) {
if (a == c || ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a1, a2, b1, b2, c1, c2;
cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
for (int l = 1; l <= 9; l++) {
for (int k = 1; k <= 9; k++) {
if (a1 == i + j && a2 == l + k && ... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
return x > 0 ? x : -x;
}
int n;
int m;
int r1, r2, c1, c2, d1, d2;
int main() {
scanf("%d%d%d%d%d%d", &r1, &r2, &c1, &c2, &d1, &d2);
for (int a = 1; a <= 9; a++)
for (int b = 1; b <= 9; b++)
if (a != b)
for (int c = 1;... |
#include <bits/stdc++.h>
using namespace std;
bool np(int x) {
if (x == 0) return 0;
if (x == 1) return 0;
if (x == 2) return 0;
if (x >= 3) {
for (int i = 2; i * i <= x; i++) {
if (i == x) continue;
if (x % i == 0) return 0;
}
}
return 1;
}
signed main() {
int y = 0, c = -1, L, n = 0,... |
#include <bits/stdc++.h>
using namespace std;
int used[15];
int main() {
int i, j, k, l, r1, r2, c1, c2, d1, d2;
scanf(" %d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
for (i = 1; i <= 9; i++) {
used[i] = 1;
for (j = 1; j <= 9; j++)
if (!used[j]) {
used[j] = 1;
for (k = 1; k <= 9... |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
float a[4] = {0};
a[2] = (r2 + c1 - d1) / 2;
int flag = 0;
if (a[2] != floor(a[2]) || a[2] <= 0 || a[2] >= 10)
cout << -1 << endl;
else {
a[3]... |
#include <bits/stdc++.h>
using namespace std;
int main() {
bool test = true;
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
for (int k = 1; k < 10; k++) {
for (int l = 1; l < 10; l++) {
if (i + j == r... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (int i = 1; i < 10; i++)
for (int j = 1; j < 10; j++)
for (int k = 1; k < 10; k++)
for (int l = 1; l < 10; l++) {
if (i == j || i == k || i == l || j == k... |
#include <bits/stdc++.h>
using namespace std;
long long n, caseno, r1, r2, c1, c2, d1, d2;
long long a[200005];
void ResetAll() {}
void Input() {
scanf("%lld%lld%lld%lld%lld%lld", &r1, &r2, &c1, &c2, &d1, &d2);
}
bool Ok(int a, int b, int c, int d) {
if (a + b != r1) return 0;
if (c + d != r2) return 0;
if (a +... |
#include <bits/stdc++.h>
int main() {
int r1, r2, c1, c2, d1, d2;
scanf("%d%d%d%d%d%d", &r1, &r2, &c1, &c2, &d1, &d2);
int flag = 0;
for (int a = 1; a <= 9; a++) {
for (int b = 1; b <= 9; b++) {
for (int c = 1; c <= 9; c++) {
for (int d = 1; d <= 9; d++) {
if (a + b == r1 && c + d ==... |
#include <bits/stdc++.h>
using namespace std;
char sl = '\n';
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
pair<int, int> r, c, d;
cin >> r.first >> r.second;
cin >> c.first >> c.second;
cin >> d.first >> d.second;
for (int i = 1; i <= 9; ++i) {
for (int j = 1;... |
#include <bits/stdc++.h>
using namespace std;
int main() {
bool ok = false;
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
do {
if (a[0] + a[1] == r1 && a[2] + a[3] == r2 && a[0] + a[2] == c1 &&
a[1] + a[3] == c2 && a[0] + a[3] == d1 && ... |
#include <bits/stdc++.h>
int main() {
int r1, r2, d1, d2, c1, c2, a, b, c, d;
scanf("%d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
a = (c1 + d1 - r2) / 2;
b = c1 - a;
c = r1 - a;
d = r2 - b;
if (a != b && a != c && a != d && b != c && b != d && c != d && a && b && c &&
d && a <= 9 && b <= 9 && ... |
#include <bits/stdc++.h>
using namespace std;
int a[111111], b[111111], n, k, i, j, p, f[111111], w, ans, m1, m2, m3, m4, m5,
m6, q, z, x, y;
int main() {
cin >> m1 >> m2 >> m3 >> m4 >> m5 >> m6;
if ((m2 + m3 + m5) % 2 == 0 && m3 <= (m2 + m3 + m5) / 2)
q = (m2 + m3 + m5) / 2 - m3;
else {
cout << "-1";... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(1e5) + 123;
const long long inf = (long long)(1e18);
const int INF = (int)(1e9);
int r1, r2, d1, d2, c1, c2;
int main() {
ios_base::sync_with_stdio(false);
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (int i = 1; i <= 9; ++i)
for (int j = 1;... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int a11 = (r1 + c1 - d2) / 2;
int a12 = r1 - a11;
int a21 = c1 - a11;
int a22 = d1 - a11;
if (a11 != a12 && a11 != a21 && a11 != a22 && a12 != a21 && a12 != a22 &&
a21 != a... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int a[N];
int main() {
int r1, r2, c1, c2, d1, d2;
scanf("%d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
int x, y, z, w;
if ((r1 - c1 + d2) % 2 != 0 || (r1 - c1 + d2 <= 0)) {
printf("-1\n");
return 0;
} else {
y = (r1 - c1 + d... |
#include <bits/stdc++.h>
int main() {
int r1, r2, c1, c2, d1, d2, x1, x2, y1, y2, flag = 0;
scanf("%d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
for (x1 = 1; x1 <= 9; ++x1)
for (x2 = 1; x2 <= 9; ++x2)
for (y1 = 1; y1 <= 9; ++y1)
for (y2 = 1; y2 <= 9; ++y2) {
if (x1 + x2 == c1 && x... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, i, j, k, l, flag = 0;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (i = 1; i <= 9; i++) {
for (j = 1; j <= 9; j++) {
for (k = 1; k <= 9; k++) {
for (l = 1; l <= 9; l++) {
if (i + k == r1 and i + j ==... |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2, A, B, C, D;
int main() {
scanf("%d%d%d%d%d%d", &r1, &r2, &c1, &c2, &d1, &d2);
for (A = 1; A <= 9; ++A)
for (B = 1; B <= 9; ++B)
for (C = 1; C <= 9; ++C)
for (D = 1; D <= 9; ++D)
if (A + B == r1 && C + D == r2 && A ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, flag = 0;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
if (r1 >= 18 || r2 >= 18 || c1 >= 18 || c2 >= 18 || d1 >= 18 || d2 >= 18) {
} else {
int wc, xc, yc, zc;
for (int w = 1; w < 10; w++) {
wc = w;
int x = r1... |
#include <bits/stdc++.h>
using namespace std;
int a[6];
vector<int> v;
int main() {
for (int i = 0; i < 6; i++) scanf("%d", &a[i]);
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
for (int k = 1; k <= 9; k++) {
for (int l = 1; l <= 9; l++) {
if (i + j == a[0] && k + l == a[... |
#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)1e5 + 5;
int r1, r2, c1, c2, d1, d2;
int a = -1, b = -1, c = -1, d = -1;
void gen() {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
for (int k = 1; k <= 9; k++) {
for (int l = 1; l <= 9; l++) {
if (i + j == ... |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2;
int a[5][5];
int main() {
scanf("%d %d %d %d %d %d\n", &r1, &r2, &c1, &c2, &d1, &d2);
for (int i = 1; i <= 9; i++)
for (int j = 1; j <= 9; j++)
for (int k = 1; k <= 9; k++)
for (int l = 1; l <= 9; l++) {
if (i != j... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
bool ok = 1;
int a, b, c, d;
if (!((d2 + r1 - c1) & 1))
b = (d2 + r1 - c1) / 2;
else
ok = 0;
if (!((d2 - r1 + c1) & 1))
c = (d2 - r1 + c1) / 2;
else
ok = 0;
a... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[100][100];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
cin >> a[i][j];
}
}
int r1 = a[0][0];
int r2 = a[0][1];
int c1 = a[1][0];
int c2 = a[1][1];
int d1 = a[2][0];
int d2 = a[2][1];
int A, B, C, D;
A = ... |
#include <bits/stdc++.h>
using namespace std;
long long t, n;
signed main() {
long long r1, r2, c1, c2, d1, d2, x1, x2, x3, x4;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
if (r1 == 1 || r2 == 1 || c1 == 1 || c2 == 1 || d1 == 1 || d2 == 1) {
cout << -1 << endl;
return 0;
}
if (r1 > 17 || r2 > 17 || c1 > ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int z = (r2 + c1 - d1) / 2, x = c1 - z, y = d2 - z, l = r2 - z;
if (z == x ||
((r1 + r2) != (c1 + c2) || (r1 + r2) != (d1 + d2) ||
(d1 + d2) != (c1 + c2)) ||
x == y ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d;
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
b = (r2 - c1 + d1) / 2;
a = r2 - b;
c = c2 - b;
d = d1 - b;
if (a != b && a != c && a != d && b != c && b != d && c != d && a > 0 &&
a <= 9 && b > 0 && b ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int a11 = (r1 + c1 - d2) / 2;
int a12 = r1 - a11;
int a21 = c1 - a11;
int a22 = d1 - a11;
if (a11 != a12 && a11 != a21 && a11 != a22 && a12 != a21 && a12 != a22 &&
a21 != a... |
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592654;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long fib(int n) {
return (((1 / sqrt(5)) * (pow((1 + sqrt(5)) / 2, n)) -
((1 /... |
#include <bits/stdc++.h>
using namespace std;
bool prime(int x) {
if (x == 1)
return false;
else if (x == 2)
return true;
for (int i = 2; i * i <= x; i++) {
if (x % i == 0) return false;
}
return true;
}
void fun2(int t) {
if (t == 1) {
cout << "*";
return;
}
cout << "*";
return fu... |
#include <bits/stdc++.h>
using namespace std;
const int M = 1024;
int s[M], b[M];
int main() {
int r1, r2, c1, c2, d1, d2;
while (~scanf("%d%d%d%d%d%d", &r1, &r2, &c1, &c2, &d1, &d2)) {
bool flag = false;
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
for (int k = 1; k < 10; k++... |
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b, c, d, x, r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
x = d2 - c1;
b = (r1 + x) / 2;
a = r1 - b;
c = d2 - b;
d = d1 - a;
if ((a + b) == r1 && (c + d) == r2 && (a + c) == c1 && (b + d) == c2 &&
(a + d) == d1... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (int a1 = 1; a1 <= 9; ++a1) {
for (int a2 = 1; a2 <= 9; ++a2) {
for (int a3 = 1; a3 <= 9; ++a3) {
for (int a4 = 1; a4 <= 9; ++a4) {
if (a1 == a2 || a1 == ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, d1, d2, c1, c2, a, b, c, d;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
a = (c1 + d1 - r2) / 2;
c = c1 - a;
b = r1 - a;
d = r2 - c;
if (a >= 1 && a <= 9 && b >= 1 && b <= 9 && d >= 1 && d <= 9 && c >= 1 &&
c <= 9) {
if (a == b |... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int a, b, c, d;
if ((c1 + r1 - d2) % 2 != 0 || (c1 + r1 - d2) / 2 > 9 ||
(c1 + r1 - d2) / 2 < 1) {
cout << -1 << endl;
return 0;
} else {
a = (c1 + r1 - d2) / 2;
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, c1, c2, r1, r2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int x[10] = {0};
c = ((c1 - r1) + d2) / 2;
d = r2 - c;
a = c1 - c;
b = r1 - a;
if (a > 9 || a < 1 || b > 9 || b < 1 || c > 9 || c < 1 || d > 9 || d < 1) {
cout ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int a, b, c, d, m = 1;
for (int i = 1; i < 10; i++) {
a = i;
b = r1 - a;
d = d1 - a;
c = c1 - a;
if (b != a && b != c && b != d && c != d && c != a && d != a && a <... |
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const double pi = 3.14159265359;
int r1, r2, c1, c2, d1, d2;
int main() {
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (int a = 1; a <= 9; a++) {
for (int b = 1; b <= 9; b++) {
for (int c = 1; c <= 9; c++) {
for (int d = 1; d <= 9; d... |
#include <bits/stdc++.h>
using namespace std;
void fast_IO_file() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main() {
fast_IO_file();
long long int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
long long int flag = 0, a, b, c, d;
for (long long int i = 1; i < 10; i++) {
... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T a, T1 b) {
if (b > a) a = b;
return a;
}
template <typename T, typename T1>
T amin(T a, T1 b) {
if (b < a) a = b;
return a;
}
template <typename T>
T amod(T a) {
if (a < 0) a = -a;
return a;
}
void solve() {
long lon... |
#include <bits/stdc++.h>
int main() {
int a, b, c, d, e, f, flag = 1, q, w, i, j;
scanf("%d%d", &a, &b);
scanf("%d%d", &c, &d);
scanf("%d%d", &e, &f);
for (i = 1; i <= 9; i++) {
for (j = 1; j <= 9; j++) {
q = a - i;
w = b - j;
if (i + j == c && q + w == d && i + w == e && q + j == f && i... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mod1 = 998244353;
const long long inf = 1e18;
long long r1, r2, c1, c2, d1, d2;
void solve() {
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (long long i = (1); i < (10); i++)
for (long long j = (1); j < (10); j++)
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int r1, r2, c1, c2, d1, d2, w, x, y, z;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
w = (d1 + c1 - r2) / 2;
x = r1 - w;
y = c1 - w;
z = r2 - y;
set<int> s;
s.insert(w);
s.insert(x);
s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.