solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
#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... | 7 | CPP |
#include <bits/stdc++.h>
int main() {
int r1, r2, c1, c2, d1, d2;
scanf("%d %d\n", &r1, &r2);
scanf("%d %d\n", &c1, &c2);
scanf("%d %d", &d1, &d2);
int a, b, c, d;
b = (r1 - c1 + d2) / 2;
c = d2 - b;
a = c1 - c;
d = c2 - b;
if (a != b && b != c && c != d && d != a && a != c && b != d && a > 0 &&
... | 7 | CPP |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
for a in range(1,10):
for b in range(1,10):
if b==a:continue
for c in range(1,10):
if c==a or c==b:continue
for d in range(1,10):
if d==c or d==a or d==b:continue
if a+b==r1 and\
c+d==r2 and\
a+... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 11;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> 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 t = 1; t <= 9; t++)
if (i != j && i !=... | 7 | CPP |
#include <bits/stdc++.h>
int main() {
int r1, r2, c1, c2, d1, d2;
while (scanf("%d%d%d%d%d%d", &r1, &r2, &c1, &c2, &d1, &d2) != EOF) {
int n = 0;
int a, b, c, d;
for (a = 1; a <= 9; a++) {
for (b = 1; b <= 9; b++) {
for (c = 1; c <= 9; c++) {
for (d = 1; d <= 9; d++) {
... | 7 | CPP |
def check(x, y, z, w):
if x + y == r1 and z + w == r2 and x + z == c1 and y + w == c2 and x + w == d1 and y + z == d2:
return True
else:
return False
def equal(x, y, z, w):
if x != y and x != z and x != w and y != z and y != w and z != w:
return True
else:
return False
... | 7 | PYTHON3 |
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
a=0 ;b=0;c=0;d=0
if (r1+c1-d2)%2==0:
a = (r1+c1-d2)//2
if (r1+c2-d1)%2==0:
b = (r1-d1+c2)//2
if (r2+c1-d1)%2==0:
c = (r2-d1+c1)//2
if (c2+d1-r1)%2==0:
d = (c2+d1-r1)//2
set1 = {a,b,c,d}
# print(set1)
if 0<... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, k;
scanf("%d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
if ((c1 + d1 - r2) % 2 == 1)
printf("-1\n");
else {
k = (c1 + d1 - r2) / 2;
if (k == (r1 - k) || k == (c1 - k) || k == (d1 - k) || r1 == c1 ||
r... | 7 | CPP |
import itertools
r1,r2=map(int, input().split())
c1,c2=map(int, input().split())
d1,d2=map(int, input().split())
flag=False
for a,b,c,d in itertools.permutations(range(1,10),4):
if a+b==r1 and c+d==r2 and a+c==c1 and b+d==c2 and a+d==d1 and b+c==d2:
print(a,b)
print(c,d)
flag=True
... | 7 | PYTHON3 |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
for r in range(1,10):
for rr in range(1,10):
for c in range(1,10):
for cc in range(1,10):
l=[r,rr,c,cc]
if r+rr==c1 and r+c==r1 and r+cc==d1 and rr+c==d2 and rr+cc==r2 and len(set(l))==4:
print(r,c)
pri... | 7 | PYTHON3 |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
l1,l2,count=[],[],0
for i in range(1,10):
for j in range(1,10):
if i+j==r1 and i!=j:l1.append([i,j])
if i+j==r2 and i!=j:l2.append([i,j])
for k in range(len(l1)):
for l in range(len(l2)):
if l1[k... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, flag;
cin >> 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 n = 1; n <= 9; n++) {
if (i != j && i != k && i !=... | 7 | CPP |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
a=[[0,0],[0,0]]
def debug(x):
for i in range(2):
for j in range(2):
print(a[i][j],end=" ")
print()
def valid():
if a[0][0]+a[1][1]==d1 and a[0][1]+a[1][0]==d2:
for i in range(2):
... | 7 | PYTHON3 |
def main():
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
x1 = -0.5 * r2 + -0.5 * c2 + d1 + 0.5 * d2
x2 = -0.5 * r2 + 0.5 * c2 + 0.5 * d2
x3 = 0.5 * r2 + -0.5 * c2 + 0.5 * d2
x4 = 0.5 * r2 + 0.5 * c2 + -0.5 * d2
solutions = {x1,... | 7 | PYTHON3 |
list = [1,2,3,4,5,6,7,8,9]
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
a = (d1 - r2 + c1)//2
d = (r2 - c1 + d1)//2
b = r1 - a
c = r2 - d
if a in list and b in list and c in list and d in list and a!=b and a!=c and a!=d and b!=c and c!=d and b!=d:
print(a... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int a1 = ((r1 + c1 - d2)) % 2 == 0 ? ((r1 + c1 - d2) / 2) : -1;
int a2 = ((r1 + c2 - d1)) % 2 == 0 ? ((r1 + c2 - d1) / 2) : -1;
int a3 = ((r2 + c1 - d1)) % 2 == 0 ? ((r2 + c1 - d1) /... | 7 | CPP |
from functools import reduce
from operator import *
from math import *
from sys import *
from string import *
setrecursionlimit(10**7)
dX= [ 0, 0, 1,-1, 1,-1, 1,-1]
dY= [ 1,-1, 0, 0, 1,-1,-1, 1]
RI=lambda: list(map(int,input().split()))
RS=lambda: input().rstrip().split()
###############################################... | 7 | PYTHON3 |
import math
y = [int(i) for i in input().split()]
r2 = y[0]
r1 = y[1]
y = [int(i) for i in input().split()]
c1 = y[0]
c2 = y[1]
y = [int(i) for i in input().split()]
d1 = y[0]
d2 = y[1]
for i in range(1,10):
a = i
b = r2-i
c = c1-i
d = d1-i
set1 = {a,b,c,d}
if(len(set1)!=4): continue;
... | 7 | PYTHON3 |
r1 ,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1 , d2 = map(int,input().split())
for a1 in range(1 , 10):
for a2 in range(1,10):
for a3 in range(1,10):
for a4 in range(1 ,10):
if a1 == a2 or a1 == a3 or a1 == a4 or a2 == a3 or a2 == a4 or a3 == a4:
pass
elif a1 + a2 == r1 and a3 ... | 7 | PYTHON3 |
r=[int(i)for i in input().split()]
c=[int(i)for i in input().split()]
d=[int(i)for i in input().split()]
a=(d[0]-r[1]+c[0])//2
b= r[0]-a
y= c[0]-a
z= d[0]-a
if (a>9 or a<=0) or (b>9 or b<=0) or (y>9 or y<=0) or (z>9 or z<=0) or (a==b) or (a==c)or (a==y) or (a==z) or (z==y) or (z==c) or (b==z) or (c==y) or (c==b... | 7 | PYTHON3 |
r1,r2= map(int, input().split())
c1,c2= map(int, input().split())
d1,d2= map(int, input().split())
# arr =[int(x) for x in input().split()]
y=(r1-c1+d2)//2
x=r1-y
n=c2-y
m=r2-n
ar=[x,y,m,n]
ar = sorted(set(ar))
if len(ar)==4 and ar[0]>0 and ar[3]<10 and r1==x+y and c1 == x+m and d1 == x+n:
print(str(x),str(y))
... | 7 | PYTHON3 |
#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 <= 9; ++i) {
bool print = true;
int arr[30] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, f;
cin >> a >> b >> c >> d >> e >> f;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
for (int k = 1; k <= 9; k++) {
for (int g = 1; g <= 9; g++) {
if (i + j == a && k + g == b && i + k == c && ... | 7 | CPP |
#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;
a = (r1 + c1 - d2) / 2;
b = r1 - a;
c = d2 - b;
d = r2 - c;
int x = c1 + c2 - d1 - d2;
int y = d1 + d2 - r1 - r2;
if (a <= 0 || b <= 0 || c <= 0 || d <= 0 |... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, b, c, d, e, f, g, i, j, k, t, x, y, z, m, n;
int flag = 0;
cin >> a >> b >> c >> d >> e >> f;
for (x = 1; x < 10; x++) {
for (y = 1; y < 10; y++) {
for (m = 1; m < 10; m++) {
for (n = 1; n < 10; n++) {
if (x ... | 7 | CPP |
from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf
from bisect import bisect_right, bisect_left
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
rr = r1+r2
cc = c... | 7 | PYTHON3 |
from collections import Counter
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
c = 0
for i in range(1,10):
for j in range(1, 10):
for k in range(1, 10):
for l in range(1, 10):
if i+j == r1 and k+l == r2:
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
template <typename t1>
t1 gcd(t1 a, t1 b) {
return b == 0 ? a : gcd(b, a % b);
}
template <typename t1>
t1 lcm(t1 a, t1 b) {
return a * (b / gcd(a, b));
}
int main() ... | 7 | CPP |
i1 = input()
i1 = i1.split(' ')
r1 = int(i1[0])
r2 = int(i1[1])
i2 = input()
i2 = i2.split(' ')
c1 = int(i2[0])
c2 = int(i2[1])
i3 = input()
i3 = i3.split(' ')
d1 = int(i3[0])
d2 = int(i3[1])
one = int(((r1 + c1 ) - d2 ) / 2)
two = int(r1 - one)
three = int(c1 - one)
four = int(d1 - one)
if one != two and one != three ... | 7 | PYTHON3 |
#include <bits/stdc++.h>
int main() {
int r1, r2, c1, c2, d1, d2, key[2][2];
int i1, i2, i3, i4, flag = 0;
scanf("%d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
for (i1 = 1; i1 < 10; i1++) {
for (i2 = 1; i2 < 10; i2++) {
for (i3 = 1; i3 < 10; i3++) {
for (i4 = 1; i4 < 10; i4++) {
... | 7 | CPP |
# https://codeforces.com/contest/143/problem/A
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
if (r1 - c1 + d2) % 2 == 0:
m = (r1 - c1 + d2) // 2
l = r1 - m
n = c1 - l
o = c2 - m
gems = {l, m, n, o}
if len(gems) != 4:
print(-1)... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
set<int> ani;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int a11 = (r1 + c1 - d2) / 2;
int a22 = d1 - a11;
int a12 = r1 - a11;
int a21 = c1 - a11;
ani.insert(a11);
ani.insert(a12);
ani.insert(a21);
ani.insert(a22)... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int m[2][2];
for (int a = 1; a < 10; a++) {
for (int b = 1; b < 10; b++) {
for (int c = 1; c < 10; c++) {
for (int d = 1; d < 10; d++) {
if (a == b || a == ... | 7 | CPP |
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
a=[]
a.append((r1+c1-d2)//2)
a.append(r1-a[0])
a.append(d2-a[1])
a.append(d1-a[0])
if(len(set(a))!=4):
print(-1)
exit(0)
for i in a:
if(i<1 or i>9):
print(-1)
exit(0)
if(a[0]+a[1]!=r1 or a[2]+a... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
def valid(s):
if not 1 <= min(s) <= 9:
return False
elif not 1 <= max(s) <= 9:
return False
elif len(s) != len(set(s)):
return False
elif s[2] + s[3] != r2:
return Fal... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, const string& delim = " ") {
vector<string> res;
string t;
for (int i = 0; i != s.size(); i++) {
if (delim.find(s[i]) != string::npos) {
if (!t.empty()) {
res.push_back(t);
t = "";
}
} else {
... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2;
cin >> c1 >> c2;
cin >> 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++) {
if (a != b && a != c... | 7 | CPP |
#include <bits/stdc++.h>
int main() {
int r1, r2, c1, c2, d1, d2;
std::cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int ii, j, jj;
for (int i = 1; i != 10; ++i) {
ii = r1 - i;
j = c1 - i;
jj = d1 - i;
if (ii > 0 && ii < 10 && j > 0 && j < 10 && jj > 0 && jj < 10 &&
j + ii == d2 && j + jj == ... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2, ans = 0, i, j, k, l;
int main() {
cin >> r1 >> r2;
cin >> c1 >> c2;
cin >> d1 >> d2;
for (i = 1; i < 10; i++) {
for (j = 1; j < 10; j++) {
for (k = 1; k < 10; k++) {
for (l = 1; l < 10; l++) {
if (i + k == c1 &... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
bool eshta = false;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
if (i == j) continue;
for (int c = 1; c <= 9; c++) {
if (i == c || j == c) con... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int x1 = (d1 - r2 + c1) / 2;
int y1 = r1 - x1;
int x2 = c1 - x1;
int y2 = (r2 - c1 + x1);
if (x1 == x2 || x1 == y1 || x1 == y2 || x2 == y1 || x2 == y2 || y1 == y2) {
cout << ... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
int a, b, c, d, ok;
ok = 0;
cin >> 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 || a ==... | 7 | CPP |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
c=0
for a in range (1,10):
for b in range (1,10):
for x in range (1,10):
for y in range (1,10):
if a +b ==r1 and x+y==r2 and a+x== c1 and b+y==c2 and a+y==d1 and b+x==d2 and len(set([a,b,... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 44;
int main() {
int r1, r2, c1, c2, d1, d2, a, b, c, d, f;
while (cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2) {
f = 0;
for (a = 1; a < 10; a++)
for (b = 1; b < 10; b++)
if (b != a && a + b == r1)
for (c = 1; c < 10; c++)
... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, z, h, c1, c2, r1, r2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
y = (r1 - c1 + d2) / 2;
x = r1 - y;
z = d2 - y;
h = c2 - y;
if (x == y || x == z || x == h || y == z || y == h || z == h || x <= 0 ||
y <= 0 || z <= 0 || h <= 0... | 7 | CPP |
#include <bits/stdc++.h>
int main() {
int x1, x2, x3, x4, num, a, b, c, d, e, f, g, h, i, j;
while (scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) != EOF) {
num = 0;
for (g = 1; g <= 9; g++) {
for (h = 1; h <= 9; h++) {
if (h == g) {
continue;
} else {
for (i = 1; i ... | 7 | CPP |
F=lambda : map(int, input().split())
R=list(range(1, 10))
r1,r2=F()
c1,c2=F()
d1,d2=F()
z = [(a,b,c,d) for a in R for b in R for c in R for d in R if len(set((a,b,c,d))) > 3 and a+b == r1 and c+d == r2 and a+c == c1 and b+d == c2 and a+d == d1 and b+c == d2]
if z:z=z[0];print(z[0],z[1]);print(z[2],z[3])
else:print(-1)... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
def ok(a, b, c, d):
if a <= 0 or b <= 0 or c <= 0 or d <= 0:
return 0
if a >= 10 or b >= 10 or c >= 10 or d >= 10:
return 0
if a == b or a == c or a == d or b == c or b == d or c == d:
return 0
if a + b ... | 7 | PYTHON3 |
r1, r2 = [int(y) for y in input().split()]
c1, c2 = [int(y) for y in input().split()]
d1, d2 = [int(y) for y in input().split()]
a = (r1+c1-d2)//2
b = r1 - a
c = c1 - a
d = d1 - a
if a not in range(1,10) or b not in range(1,10) or c not in range(1,10) or d not in range(1,10):
print(-1)
elif a == b or a == c or a ==... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int num1, num2, num3, num4, flag = 0;
for (int i = 1; i < r1; i++) {
num1 = i;
num2 = r1 - i;
if (c1 - num1 > 0 && num1 <= 9) {
flag++;
num3 = c1 - num1;
} ... | 7 | CPP |
from itertools import permutations
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
for a, b, c, d in permutations(range(1, 10), 4):
if a + b == r1 and c + d == r2 and a + c == c1 and b + d == c2 and a + d == d1 and c + b == d2:
print(a, b)
pri... | 7 | PYTHON3 |
import math
def main():
r1,r2 = [int(x) for x in input().split()]
c1,c2 = [int(x) for x in input().split()]
d1,d2 = [int(x) for x in input().split()]
a = math.floor((r1 - c2 + d1)/2)
b = r1 - a
c = c1 - a
d = d1 - a
if a == b or a == c or a == d or b == c or b == d or c == d:
pr... | 7 | PYTHON3 |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
a=(r1+c1-d2)/2
b=r1-a;c=c1-a;d=d1-a
A=set()
A.add(a);A.add(b);A.add(c);A.add(d)
if(a>9 or b>9 or c>9 or d>9):
print("-1")
elif(a<1 or c<1 or b<1 or d<1):
print("-1")
elif(a!=int(a)):
print("-1")
elif(len(A)<4):
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
int main() {
int x1, x2, x3, x4, r1, r2, c1, c2, d1, d2;
scanf("%d%d%d%d%d%d", &r1, &r2, &c1, &c2, &d1, &d2);
x1 = (r1 + c1 - d2) / 2;
x2 = r1 - x1;
x3 = (c1 + d2 - r1) / 2;
x4 = r2 - x3;
if ((x1 >= 1 && x1 <= 9) && (x2 >= 1 && x2 <= 9) && (x3 >= 1 && x3 <= 9) &&
(x4 >= 1 &&... | 7 | CPP |
#include <bits/stdc++.h>
int main() {
int r1, r2, c1, c2, d1, d2, x;
scanf("%d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
if ((r1 + r2) == (c1 + c2) && (c1 + c2) == (d1 + d2) &&
(r1 + r2) == (d1 + d2)) {
x = (d1 + r1 - c2) / 2;
if (x) {
int a, b, c, d;
a = x;
b = r1 - x;
... | 7 | CPP |
r1,r2 = map(int, input().split(" "))
c1,c2 = map(int, input().split(" "))
d1,d2 = map(int, input().split(" "))
for a1 in range(1,10):
for a2 in range(1,10):
for a3 in range(1,10):
for a4 in range(1,10):
if (a1!=a2)and(a1!=a3)and(a1!=a4)and(a2!=a3)and(a2!=a4)and(a3!=a4)and(a1+a2==... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int r[2], c[2], d[2];
int n[3];
int cntn = 0;
int main() {
cin >> r[0] >> r[1] >> c[0] >> c[1] >> d[0] >> d[1];
for (int i = 1; i <= 9; i++)
for (int j = 1; j <= 9; j++)
if (i + j == r[0] && i != j)
for (int q = 1; q <= 9; q++)
if (i != q && ... | 7 | CPP |
import math
r = list(map(int, input().split()))
c = list(map(int, input().split()))
d = list(map(int, input().split()))
x3 = math.ceil((c[0] + d[1] - r[0])/2)
x1 = c[0] - x3
x2 = d[1] - x3
x4 = r[1] - x3
#print(x1,x2)
#print(x3,x4)
if (x3 > 9) or (x1 > 9) or (x2 > 9) or (x4 > 9) or (x3 <= 0) or (x1 <= 0) or (x2 <= 0)... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int r1, r2, c1, c2, d1, d2;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> r1 >> r2;
cin >> c1 >> c2;
cin >> d1 >> d2;
int a, b, c, d;
int first_sum = r1 - c2 + d1;
if (first_sum % 2 == 0) {
a = first_sum / ... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long c1, c2, r1, r2, d1, d2;
bool flag = false;
cin >> 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 m = 1; m <= 9; m++) {
if (i != j &&... | 7 | CPP |
r1, r2 = map(int,input().split())
c1, c2 = map(int,input().split())
d1, d2 = map(int,input().split())
l = []
for i in range(1,c2+1) :
l.append((c2-i,i))
for i in l :
x2,y2 = i
x1 = r1 - x2
y1 = c1 - x1
a = [x1+y1 == c1, x2+y2 == c2, x1+x2 == r1,y1+y2 == r2,
x1+ y2 == d1, x2 + y1 == d2, len(set([x1,x2... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
int a, b, c, d;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
a = (r1 - d2 + c1) / 2;
b = r1 - a;
c = c1 - a;
d = c2 - b;
if (a < 1 || b < 1 || c < 1 || d < 1 || a > 9 || b > 9 || c > 9 || d > 9) {
cout << "-1";
} el... | 7 | CPP |
def check(a , b , c, d):
if (a==b):
return False
if (a==c):
return False
if (a==d):
return False
if (b==c):
return False
if (b==d):
return False
if (c==d):
return False
return True
r=(input().split())
c=(input().split())
d=(input().split())
r... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int num[10], cells[10];
bool used[10];
bool bt(int idx) {
if (idx == 4) {
if (num[0] == cells[0] + cells[1] && num[1] == cells[2] + cells[3] &&
num[2] == cells[0] + cells[2] && num[3] == cells[1] + cells[3] &&
num[4] == cells[0] + cells[3] && num[5] ==... | 7 | CPP |
"""
a b
c d
a+b=r1
c+d=r2
a+c=c1
b+d=c2
a+d=d1
b+c=d2
a2+c+b= r1+c1
2a+d2=r1+c1
a=(r1+c1-d2)//2
b=r1-a
c=d2-b
d=r2-c
"""
r1, r2 = map(int, input().strip().split())
c1, c2 = map(int, input().strip().split())
d1, d2 = map(int, input().strip().split())
a=(r1+c1-d2)//2
b=r1-a
c=d2-b
d=r2-c
if len(set([a, b, c, d]))... | 7 | PYTHON3 |
#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 a = 1; a < 10; ++a) {
for (int b = 1; b < 10; ++b) {
for (int c = 1; c < 10; ++c) {
for (int d = 1; d < 10; ++d) {
if (a + d == d1 && c + b == d2 && ... | 7 | CPP |
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2= map(int,input().split())
l = [r1,r2,c1,c2,d1,d2]
if len({r1+r2,c1+c2,d1+d2}) != 1:
print(-1)
else:
a = (r1-c2+d1)//2
b = r1-a
c = c1-a
d= d1-a
s = len({a,b,c,d})
if (a >0 and a<=9) and (b >0 and b<=9) and (c >0 and c<=... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
num = [1,2,3,4,5,6,7,8,9]
for i in range(1,10):
x1 = i
x2 = c1 - x1
y1 = r1 - x1
y2 = r2 - x2
if(x1 != x2 and x1 != y1 and x1 != y2 and x2 != y1 and x2 != y2 and y1 != y2) and (x1 in num and x... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2;
bool flag;
int main() {
while (~scanf("%d%d%d%d%d%d", &r1, &r2, &c1, &c2, &d1, &d2)) {
flag = true;
for (int i = 1; i <= 9; i++)
for (int j = 1; j <= 9; j++)
if (j != i)
for (int k = 1; k <= 9; k++)
i... | 7 | CPP |
r1,r2 = [int(x) for x in input("").split()]
c1,c2 = [int(x) for x in input("").split()]
d1,d2 = [int(x) for x in input("").split()]
for i in range(1, 9+1):
for j in range(1, 9+1):
for k in range(1, 9+1):
for l in range(1, 9+1):
if len(set([i,j,k,l])) != 4:
con... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
for i in range(1,10):
for j in range(1,10):
if i == j:
continue
for k in range(1,10):
if i == k or j == k:
continue
for l in range(1,10):
if i == l or j == l or k == l:
continue
if i... | 7 | PYTHON3 |
#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);
for (int i = 1; i < 10; i++)
for (int j = 1; j < 10; j++)
if (i + j == r1)
for (int k = 1; k < 10; k++)
if (j + k == d2 && i + k == c1)
for (int l = 1; l <... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main(void) {
double c1, c2, r1, r2, d1, d2, i, j, k, l;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
l = (r2 - d2 + c2) / 2;
i = d1 - l;
k = c1 - i;
j = d2 - k;
if ((i >= 1 && i <= 9) && (j >= 1 && j <= 9) && (k >= 1 && k <= 9) &&
(l >= 1 && l <= 9) && (... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int p, q, r, s;
p = ((d1 + r1 + c1) - (d2 + c2 + r2) / 2) / 3;
q = r1 - p;
r = c1 - p;
s = d1 - p;
if (p != q && p != r && p != s && q != r && q != s && r != s) {
if ((p > ... | 7 | CPP |
r1, r2 = map(int, input().split(" "))
c1, c2 = map(int, input().split(" "))
d1, d2 = map(int, input().split(" "))
i,j,k,z=9,9,9,9
while(i>0):
j=i-1
while(j>0):
k=j-1
while(k>0):
z=k-1
while(z>0):
q, w, r, e = i, j, k, z
for _ in range(4):
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
string toString(T x) {
if (x == 0) return "0";
bool negative = x < 0;
string res;
while (x) {
res.push_back('0' + x % 10);
x /= 10;
}
if (negative) res.push_back('-');
reverse(res.begin(), res.end());
return res;
}
void ioFromFi... | 7 | CPP |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
def f():
for a in range(1,10):
for b in range(1,10):
for c in range(1,10):
for d in range(1,10):
if len(set([a,b,c,d]))==4:
if r1==a+b and r2==c+d and c1==a+c and c2==b+d and d1==a+d and d2==b+c:
ret... | 7 | PYTHON3 |
import itertools
sum_to_sockets = [
(0, 1),
(2, 3),
(0, 2),
(1, 3),
(0, 3),
(1, 2)
]
sums = []
for _ in range(3):
sums += list(map(int, input().split()))
for seq in itertools.permutations(range(1, 10), r=4):
if all([seq[sum_to_sockets[i][0]] + seq[sum_to_sockets[i][1]] == sums[i]
... | 7 | PYTHON3 |
I = lambda: map(int, input().split())
r1, r2 = I()
c1, c2 = I()
d1, d2 = I()
for a in range(1, 10):
b, c, d = r1-a, c1-a, d1-a
if ( 0<b<=9 and 0<c<=9 and 0<d<=9
and b+d==c2 and c+d==r2 and b+c==d2 and len({a,b,c,d})>3
):
print(a, b)
print(c, d)
break
else:
print(-1) | 7 | PYTHON3 |
#include <bits/stdc++.h>
int main(void) {
int r1, r2, c1, c2, d1, d2, i, j, k, l;
scanf("%d%d", &r1, &r2);
scanf("%d%d", &c1, &c2);
scanf("%d%d", &d1, &d2);
for (i = 1; i <= 9; i++)
for (j = r1 - i; j <= 9; j++)
for (k = c1 - i; k <= 9; k++)
for (l = d1 - i; l <= 9; l++) {
if (j >=... | 7 | CPP |
#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 <= 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 + k == c1 && j + l == c2 && i + j ==... | 7 | CPP |
#include <bits/stdc++.h>
int main(void) {
int r1, r2;
int c1, c2;
int d1, d2;
int countr1 = 0;
int countr2 = 0;
int a[100];
int b[100];
int i, j, k;
scanf("%d%d", &r1, &r2);
getchar();
scanf("%d%d", &c1, &c2);
getchar();
scanf("%d%d", &d1, &d2);
for (i = 1, j = 0; i <= 9; i++) {
if (r1 -... | 7 | CPP |
def read():
return map(int, input().split())
r1, r2 = read()
c1, c2 = read()
d1, d2 = read()
a11 = (r1 + c1 - d2) // 2
a21 = c1 - a11
a22 = d1 - a11
a12 = r1 - a11
if a11 + a12 == r1 and a21 + a22 == r2 and a11 + a21 == c1 and a12 + a22 == c2\
and a11 + a22 == d1 and a21 + a12 == d2 and 1 <= a11 <= 9 and 1 <= a1... | 7 | PYTHON3 |
r=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
d=[int(x) for x in input().split()]
w=(d[0]-r[1]+c[0])//2
x=r[0]-w
y=c[0]-w
z=d[0]-w
if 1<=w<=9 and 1<=x<=9 and 1<=y<=9 and 1<=z<=9 and w!=x and w!=y and w!=z and x!=y and x!=z and y!=z:
print(w,x)
print(y,z)
else:
print(-1)
| 7 | PYTHON3 |
try:
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
b=(r1-d1+c2)
if(b%2==0):
b=b//2
a=r1-b
c=d2-b
d=c2-b
if(a>0 and a<10 and b>0 and b<10 and c>0 and c<10 and d<10 and d>0):
if(a==b or a==c or a==... | 7 | PYTHON3 |
#include <bits/stdc++.h>
const long long mod = (long long)1e9 + 7;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long e, f, g, h, i, j;
cin >> e >> f >> g >> h >> i >> j;
bool valid = false;
for (long long a = 1; a <= 9; a++) {
for (long long b = 1; b <= 9; b++)... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, n[4], b[4];
cin >> r1 >> r2;
cin >> c1 >> c2;
cin >> d1 >> d2;
n[0] = (d1 + c1 - r2) / 2;
b[0] = n[0];
n[1] = (c2 + d2 - r2) / 2;
b[1] = n[1];
n[2] = (c1 + d2 - r1) / 2;
b[2] = n[2];
n[3] = (c2 + d1 - r1) / 2;
... | 7 | CPP |
import math
def invalid(a, b, x):
if (a+b==x):
return 0
else:
return 1
r1 , r2 = input().split()
r1 = int(r1)
r2 = int(r2)
c1, c2 = input().split()
c1 = int(c1)
c2 = int(c2)
e1, e2 = input().split()
e1 = int(e1)
e2 = int(e2)
x = 9
flag = 1
while(x):
x -= 1
a1, a2, a3, a4 = 0, 0, ... | 7 | PYTHON3 |
#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 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 ... | 7 | CPP |
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
"""========main code==============="""
t=1
#t=ii()
for _ in range(t):
a,b=ml()
c,d=ml()
e,f=ml()
flag=0
ans=[]
for i i... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2;
int main() {
scanf("%d%d%d%d%d%d", &r1, &r2, &c1, &c2, &d1, &d2);
for (int i = 1; i <= 9; ++i)
for (int j = 1; j <= 9; ++j)
for (int ii = 1; ii <= 9; ++ii)
for (int jj = 1; jj <= 9; ++jj) {
if (i != j && i != ii &&... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2;
cin >> c1 >> c2;
cin >> d1 >> d2;
int a1, a2, a3, a4;
int flag = 0;
for (a1 = 1; a1 <= 9; a1++) {
for (a2 = 1; a2 <= 9; a2++) {
for (a3 = 1; a3 <= 9; a3++) {
for (a4 = 1; a4 <= 9; a4++... | 7 | CPP |
row = list(map(int, input().strip().split()))
col = list(map(int, input().strip().split()))
diag = list(map(int, input().strip().split()))
(r1, r2) = (row[0], row[1])
(c1, c2) = (col[0], col[1])
(d1, d2) = (diag[0], diag[1])
lst = [[(r1 + c1 - d2) / 2, (d2 + r1 - c1) / 2], [(d2 + c1 - r1) / 2, (2*c2 + c1 - d2 - r1) / 2... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int maxn = 1e5 + 5;
int r1, r2, c1, c2, d1, d2;
int ans[5][5];
int main() {
while (cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2) {
int flag = 0;
for (int i = 1; i <= 9; i++) {
ans[0][0] = i;
ans[0][1] = r1 - i;
ans[1][0]... | 7 | CPP |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
d = int((d1-(r1-c2))/2)
a = r1+d-c2
b = r1-a
c=c1-a
if ((c+b==d2)&(a+d==d1) &(a+b==r1) &(c+d==r2) &(a+c==c1)&(b+d==c2) &(a!=b) &(a!=c) & (a!=d) & (b!=c) & (b!=d) &(c!=d) &(0<a<=9) &(0<b<=9)&(0<c<=9)&(0<d<=9))... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2;
int main() {
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
vector<int> nums;
if (r1 + r2 == c1 + c2 && c1 + c2 == d1 + d2) {
int x = (d1 + r1 - c2);
int y = (c2 + d2 - r2);
int w = (d1 + c2 - r1);
int z = (2 * c1 - d1 - r1 + c2);... | 7 | CPP |
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
y = (d2+(r2-c2))//2
x = d2-y
w = r1-x
z = d1-w
if not 1<=w<=9 or not 1<=x<=9 or not 1<=y<=9 or not 1<=z<=9:
print(-1)
exit()
if w == x or w == y or w == z or x == y or x == z or y == z:
print(-1)
exit()
if... | 7 | PYTHON3 |
from sys import stdin,stdout
i1 = lambda : int(stdin.readline())
iia = lambda : map(int, stdin.readline().split())
isa = lambda: stdin.readline().split()
r1, r2 = iia()
c1, c2 = iia()
d1, d2 = iia()
if (c2 + r2 - d2) % 2 == 0:
d = (c2 + r2 - d2) // 2
c = r2 - d
b = c2 - d
a = r1 - b
temp = [a, b, c... | 7 | PYTHON3 |
rs = input().strip().split(' ')
cs = input().strip().split(' ')
ds = input().strip().split(' ')
r1 = int(rs[0])
r2 = int(rs[1])
c1 = int(cs[0])
c2 = int(cs[1])
d1 = int(ds[0])
d2 = int(ds[1])
if min(r1, r2, c1, c2, d1, d2)==1:
print(-1)
else:
row1 = []
k = 1
while r1-k>0:
if k!=r1-k and k<=9 ... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, a, b, c, d;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
a = d1 - 1;
d = 1;
while (a > 0) {
b = r1 - a;
c = c1 - a;
if ((r1 == a + b) && (r2 == c + d) && (c1 == a + c) && (c2 == b + d) &&
(d2 == b + c) && (a... | 7 | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.