solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
z=0
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
for x in range(1,10):
x2=r1-x
x3=c1-x
if x3<r2:
x4=r2-x3
if x3+x2==d2 and x+x4==d1 and 0<x<10 and 0<x2<10 and 0<x3<10 and 0<x4<10:
if x!=x2 and x3!=x4 and x!=x4 and x3!=x2 and x!=... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
m = min(r1, r2, c1, c2, d1, d2)
i = 1
while 1:
x1 = i
x2 = c1 - x1
y1 = r1 - x1
y2 = r2 - x2
i += 1
if (x1<=0) | (x2<=0) | (y1<=0) | (y2<=0) | (x1>9) | (x2>9) | (y1>9) | (y2>9) | (x1 + y2 != ... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
a = r1 + d1 - c2
if a % 2: print(-1)
else:
a = a // 2
b = r1 - a
d = d1 - a
c = r2 - d
if c1 != a + c or c2 != b + d or d2 != b + c: print(-1)
elif len(set([a, b, c, d])) < 4 or min(a, b, c... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
x = (d1 + c1 - r2) // 2
y = r1 - x
z = c1 - x
w = d1 - x
if 1 <= x <= 9 and 1 <= y <= 9 and 1 <= z <= 9 and 1 <= w <= 9 and len(set([x, y, z, w])) == 4:
print(x, y)
print(z, w)
else:
print(-1)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void exgcd(int a, int b, int *x, int *y) {
if (b) {
exgcd(b, a % b, y, x);
(*y) = (*y) - (a / b) * (*x);
} else
*x = 1, *y = 0;
}
int main() {
std::ios::sync_with_stdio(false);
double r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
d... | 7 | CPP |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
m = min(r1, r2, c1, c2, d1, d2)
i = 1
while 1:
if m == c1:
x1 = m - i
x2 = c1 - x1
y1 = r1 - x1
y2 = c2 - y1
elif m == c2:
y1 = m - i
y2 = c2 - y1
x1 =... | 7 | PYTHON3 |
from sys import stdin, stdout
INF=1e11
# import math
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split())
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.wr... | 7 | PYTHON3 |
#include <bits/stdc++.h>
int main() {
int r1, r2, c1, c2, d1, d2, x1, x2, x3, x4;
scanf("%d %d", &r1, &r2);
scanf("%d %d", &c1, &c2);
scanf("%d %d", &d1, &d2);
x1 = r1 + c1 - d2;
x2 = r1 + c2 - d1;
x3 = r2 + c1 - d1;
x4 = r2 + c2 - d2;
if (x1 % 2 != 0)
printf("-1");
else if (x2 % 2 != 0)
pri... | 7 | CPP |
def solve():
def readinput():
return map(int, input().strip().split())
r1, r2 = readinput()
c1, c2 = readinput()
d1, d2 = readinput()
for g1 in range(1, 10):
for g2 in range(1, 10):
for g3 in range(1, 10):
for g4 in range(1, 10):
s = se... | 7 | PYTHON3 |
r1, r2 = list(map(int, input().split()))
c1, c2 = list(map(int, input().split()))
d1, d2 = list(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 ... | 7 | PYTHON3 |
from itertools import permutations
perm = permutations([1, 2, 3,4,5,6,7,8,9], 4)
x=0
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
check=True
for i in list(perm):
ans=permutations(list(i),4)
for j in list(ans):
k=list(j)
a=k[0]
b=k[1]
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
bool isprime[100000];
using namespace std;
void setprime() {
for (int i = 1; i < 100005; i++) isprime[i] = true;
isprime[0] = false;
isprime[1] = false;
for (int i = 2; i * i < 100005; i++) {
if (isprime[i] == true) {
for (int j = (2 * i); j < 100005; j += i) isprime[j] = fals... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2;
int checker(int a, int b, int c, int d) {
if ((a + c == c1) && (c + b == d2) && (c + d == r2) && (a + b == r1) &&
(a + d == d1) && (b + d == c2)) {
if (a != b && b != c && c != d && a != d && a != c && b != d) {
return 1;
} ... | 7 | CPP |
s=input('')
s1=input('')
s2=input('')
r1,r2=s.split(' ')
r1=int(r1)
r2=int(r2)
c1,c2=s1.split(' ')
c1=int(c1)
c2=int(c2)
d1,d2=s2.split(' ')
d1=int(d1)
d2=int(d2)
a=(2*r1-r2+2*c1-c2+2*d1-d2)/6
b=(2*r1-r2+2*c1+5*c2-4*d1-d2)/6
c=(-4*r1-r2+2*c1-c2+2*d1+5*d2)/6
d=(2*r1+5*r2-4*c1-c2+2*d1-d2)/6
# print(a,b,c,d)
l=[1.0,2.0,3.... | 7 | PYTHON3 |
import sys
def main():
(r1, r2) = map(int, sys.stdin.readline().split(' '))
(c1, c2) = map(int, sys.stdin.readline().split(' '))
(d1, d2) = map(int, sys.stdin.readline().split(' '))
for i in range(1, 10):
for j in range(1, 10):
for k in range(1, 10):
for l in range(1... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int x[41];
int main() {
int a, b, c, d, r1, r2, c1, c2, d1, d2, i, l, m;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
l = d1 + d2;
m = r1 + r2 + c1 + c2;
if (2 * l != m)
cout << "-1", exit(0);
else {
a = (c1 + r1 - d2) / 2;
b = c2 + d2 - r2, b = b / 2;
... | 7 | CPP |
import collections
import sys
def read_a_integer():
return int(sys.stdin.readline())
def read_a_list(dtype):
return list(map(dtype, sys.stdin.readline().split()))
def main():
r1, r2 = read_a_list(int)
c1, c2 = read_a_list(int)
d1, d2 = read_a_list(int)
if (r1 - c1 + d2) % 2:
print("-... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
g1, g2, g3, g4 = -1, -1, -1, -1
result = False
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 and i != k and i != l and ... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cer... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int OO = (int)1e8;
const double EPS = 1e-11;
int diri[] = {0, 1, -1, 0};
int dirj[] = {1, 0, 0, -1};
int arr[30];
map<char, string> m;
int main() {
int a, b, c, d, e, f;
cin >> a >> b >> c >> d >> e >> f;
for (int i = 1; i < 10; ++i) {
for (int j = 1; j < 10... | 7 | CPP |
r1,r2 =map(int, input().split())
c1,c2 =map(int, input().split())
d1,d2 =map(int, input().split())
y=0
for i in range(1,d1):
if i>9:
break
b=i
x=d1-b
if x>=1 and x<=9:
a=c1-x
if a+b==r2:
y=r1-x
z=[x,y,a,b]
if y>=1 and y<=9 and a>=1 and a<=... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
d = int(((c2 + d1)-r1) / 2)
c = int(r2 - d)
a = int(d1 - d)
b = int(c2 - d)
# print(a, b, c, d)
if a == b or a == c or a == d or b == c or b == d or c == d or\
a < 1 or b < 1 or c < 1 or d < 1 or\
a ... | 7 | PYTHON3 |
r=list(map(int,input().split()));c=list(map(int,input().split()));d=list(map(int,input().split()));ok=0
for i in range(1,10):
for j in range(1,10):
for k in range(1,10):
for e in range(1,10):
if(i!=j and i!=k and i!=e and j!=k and j!=e and k!=e and ok==0 and i+j==r[0] and k+e==r[... | 7 | PYTHON3 |
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
res = [[-1]]
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 i + k == c1 and i +l == d1 and j +l == c2 and k +l == r2 and ... | 7 | PYTHON3 |
def checking(r1, r2, c1, c2, d1, d2):
lis = [1, 2, 3, 4, 5, 6, 7, 8, 9]
ans = 0
for i in range(1, 10):
x = i
a = r1 - x
b = c1 - x
c = r2 - b
if (x != a and x != b and x != c and a != b and a != c and b != c) and (
a in lis and b in lis and c in lis an... | 7 | PYTHON3 |
r1, r2 = (int(i) for i in input().split())
c1, c2 = (int(i) for i in input().split())
d1, d2= (int(i) for i in input().split())
eq1 = r1 + c1 + d1 # 3a
eq2 = r1 + c2+ d2 # 3b
eq3 = r2 + c1 + d2 # 3c
eq4 = r2 + c2 + d1 # 3d
s = eq1 + eq2 + eq3 + eq4
s /= 6
a = (eq1-s)/2
b = (eq2-s)/2
c = (eq3-s)/2
d = (eq4-s)/2
if... | 7 | PYTHON3 |
from itertools import permutations
r1, r2 = list(map(int, input().split()))
c1, c2 = list(map(int, input().split()))
d1, d2 = list(map(int, input().split()))
for i, j, k, l in permutations(range(1, 10), 4):
if i + j == r1 and k + l == r2 and i+l == c1 and j+k == c2 and i+k == d1 and j + l == d2:
print(i,... | 7 | PYTHON3 |
import itertools
I=lambda:map(int,input().split())
a,b=I()
c,d=I()
e,f=I()
for m in itertools.combinations(range(1,10),4):
for w,x,y,z in itertools.permutations(m):
if [w+x,y+z,w+y,x+z,w+z,x+y]==[a,b,c,d,e,f]:
print(f'{w} {x}\n{y} {z}')
exit(0)
print(-1) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->ios::sync_with_stdio(0);
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int mas[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
do {
if (mas[0] + mas[1] == r1 && mas[2] + mas[3] == r2 &&
mas[0] + mas[2] == c1 && mas[1] +... | 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;
c = (c1 + r2 - d1) / 2;
a = c1 - c;
b = r1 - a;
d = r2 - c;
if ((c1 + r2 - d1) % 2 == 0)
if (a != b and a != c and a != d and b != c and b != d and c != d)
... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
bool isnumber(int a);
int main() {
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
if ((c1 + c2) != (d1 + d2)) {
cout << -1 << endl;
return 0;
}
int a = d1 + r1 - c2;
int b = r1 + c2 - d1;
int c = d2 + r2 - c2;
int d = r2 + c2 - ... | 7 | CPP |
#include <bits/stdc++.h>
int check(int i, int j, int k, int l, int r1, int r2, int c1, int c2, int d1,
int d2) {
if (i + j != r1) return 0;
if (k + l != r2) return 0;
if (i + k != c1) return 0;
if (j + l != c2) return 0;
if (i + l != d1) return 0;
if (j + k != d2)
return 0;
else
return 1... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, i, x1, x2, x3, x4;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (i = 1; i <= 9; i++) {
x1 = i;
x4 = d1 - x1;
x2 = r1 - x1;
x3 = r2 - x4;
if (x4 > 9 || x2 > 9 || x3 > 9) continue;
if (x2 == x4 || x1 == x2... | 7 | CPP |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
i = (d1 - c2 + r1) / 2
j = r1 - i
k = c1 - i
w = d1 - i
if len(set([i,j,k,w])) + sum([1<=i<=9,1<=j<=9,1<=k<=9,1<=w<=9]) == 8 and k + w == r2 and j + k == d2:
print(int(i),int(j))
print(int(k),int(w))
exit()
prin... | 7 | PYTHON3 |
######################################################################
# Write your code here
import sys
from math import *
input = sys.stdin.readline
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])
#sys.setrecursionlimit(0x100000)
# Write your code here
RI = lambda : [... | 7 | PYTHON3 |
r1 , r2 = map(int,input().split())
c1 , c2 = map(int,input().split())
d1 , d2 = map(int,input().split())
ans = [[0,0],[0,0]]
cnt = 1
while (cnt<10):
ans[0][0] = cnt
ans[0][1] = r1 - cnt
ans[1][0] = c1 - cnt
ans[1][1] = d1 - cnt
if (ans[1][0]+ans[1][1]!=r2) or (ans[0][1]+ans[1][1]!=c2) or (ans[1][0]+ans[0][1]!=d2):... | 7 | PYTHON3 |
#include <bits/stdc++.h>
int main(void) {
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);
a = (r1 - c2 + d1) / 2;
b = (c2 - r2 + d2) / 2;
c = (c1 - r1 + d2) / 2;
d = (c2 - r1 + d1) / 2;
if (a + b != r1 || a + c != c1 || a + d != d1 || b + c != d2 || b + d... | 7 | CPP |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
hallado = True
for x3 in range(1,10):
for x4 in range(1,10):
if (r1 == d1 - x4 + d2 -x3) and (r2 == x3 + x4)and (c1== d1 - x4 + x3) and (c2 == d2 - x3 + x4) and (x3 != x4) and (d1 - x4 != d2 - x3) and (... | 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 a, b, c, d;
a = (r1 + c1 - d2);
if (a % 2 != 0) {
cout << "-1" << endl;
return 0;
} else {
a = a / 2;
}
b = r1 - a;
c = c1 - a;
d = c2 - b;
if (c + d == r... | 7 | CPP |
s = input().split()
r1 = int(s[0])
r2 = int(s[1])
s = input().split()
c1 = int(s[0])
c2 = int(s[1])
s = input().split()
d1 = int(s[0])
d2 = int(s[1])
b = (r1+d2-c1)
a = r1+d1-c2
d = r2+d1-c1
c = r2+d2-c2
if a%2!=0 or a<0 or a//2>9 or b%2!=0 or b<0 or b//2>9 or c%2!=0 or c<0 or c//2>9 or d%2!=0 or d<0 or d//2>9:
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
template <class T>
T Multiply(T a, T b) {
return a * b;
}
template <class T>
T larger(T a, T b) {
return (a > b ? a : b);
}
template <class T>
T smaller(T a, T b) {
return (a < b ? a : b);
}
template <class T>
T gcd(T a, T b) {
if (b == 0) return a;
return gcd(b, ... | 7 | CPP |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
found = False
for i in range(1, 10):
if found:
break
for j in range(1, 10):
if found:
break
for k in range(1, 10):
if found:
break
... | 7 | PYTHON3 |
def intger (l):
ans=[]
for i in l :
ans.append(int(i))
return ans
r=intger(input().split())
c=intger(input().split())
d=intger(input().split())
from itertools import permutations
myFlag=False
for i in permutations(range(1,10),4):
if i[0]+i[1]==r[0] and i[2]+i[3]==r[1] and i[0]+i[2]==c[0] and i[1... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2;
scanf("%d %d", &r1, &r2);
scanf("\n");
scanf("%d %d", &c1, &c2);
scanf("\n");
scanf("%d %d", &d1, &d2);
int used[10] = {0};
for (int LT = 1; LT <= 9; LT++) {
used[LT] = 1;
int RT = r1 - LT;
if (used[RT] ||... | 7 | CPP |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
ans = [r1 + c1 - d2, r1 + c2 - d1, c1 + r2 - d1, c2 + r2 - d2]
if any([x % 2 == 1 or x // 2 not in range(1, 10) for x in ans]) or len(set(ans)) != 4:
print(-1)
else:
ans = [x // 2 for x in ans]
print(*ans[:2])... | 7 | PYTHON3 |
try:
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
a,b,c,d,=0,0,0,0
d=int((c2+r2-d2)/2)
a=int(d1-d)
b=int(c2-d)
c=int(r2-d)
if a!=b and a!=c and a!=d and b!=c and b!=d and c!=d and 0<a<10 and 0<b<10 and 0<c<10 and 0<d<10 and a+b==r1 and ... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
res = []
for a in range(1,10,1):
b = r1-a
c = c1-a
d = r2-c
if a<=9 and a>=1 and b<=9 and b>=1 and c<=9 and c>=1 and d<=9 and d>=1:
if a+b == r1 and a+c == c1 and a+d == d1 and c+d == r2 and d+b == c2 and b+... | 7 | PYTHON3 |
#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 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 && i != k... | 7 | CPP |
r=input().split()
c=input().split()
d=input().split()
def chick_list(l):
if l[0]+l[1]==int(r[0]) and l[2]+l[3]==int(r[1]) and l[0]+l[2]==int(c[0]) and l[1]+l[3]==int(c[1]) and l[0]+l[3]==int(d[0]) and l[1]+l[2]==int(d[1]):
return 1
return 0
ll=[0, 0, 0, 0]
for i in range(1,10):
ll[0] = i
f... | 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 a, b, c, d;
c = c1 + d2 - r1;
c /= 2;
a = c1 - d2 + r1;
a /= 2;
b = r1 - a;
d = d1 - a;
vector<int> x;
x.push_back(a);
x.push_back(b);
x.push_back(c);
x.push_ba... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
bool within(signed short s) { return s >= 1 && s <= 9; }
int main() {
ios_base::sync_with_stdio(0);
signed short r1, r2, c1, c2, d1, d2, a, b, c, d;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
d = (d1 - r1 + c2) / 2;
if (d * 2 != d1 - r1 + c2) {
cout << -1;
r... | 7 | CPP |
l=[]
for i in range(3) :
l+=list(map(int,input().split()))
for i in range(1,10) :
for j in range(1,10) :
for i1 in range(1,10) :
for j1 in range(1,10) :
if i+j==l[0] and i1+j1==l[1] and i+j1==l[4] and i+i1==l[2] and j+j1==l[3] and j+i1==l[5] :
... | 7 | PYTHON3 |
lock = [[0,0],[0,0]]
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
for i in range(1,10):
lock[0][0] = i
lock[0][1] = r1 -i
lock[1][0] = c1 - lock[0][0]
lock[1][1] = r2 - lock[1][0]
if lock[0][0] + lock[0][1] == r1 \
and lock[1][0] + lo... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c2, c1, d1, d2;
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 k = 1; k <= 9; k++) {
if (k == i || k == j) continue;
for (in... | 7 | CPP |
#!/usr/bin/env python
import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import (
accumulate, comb... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r1, r2, c1, c2, d1, d2, a, b, c, d;
while (cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2) {
int i, j, k, m;
bool flag = 0;
for (i = 1; i <= 9; ++i)
for (j = 1; j <= 9; ++j)
for (k = 1; k <= 9; ++k)
for (m = 1; m <= 9; ++m)
... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2;
int ans[4];
int res[4];
bool Find;
bool calc() {
if (ans[0] + ans[1] != r1) return false;
if (ans[2] + ans[3] != r2) return false;
if (ans[0] + ans[2] != c1) return false;
if (ans[1] + ans[3] != c2) return false;
if (ans[0] + ans[3] != ... | 7 | CPP |
def solve(r1,r2,c1,c2,d1,d2):
cel1 = 0
cel2 = 0
cel3 = 0
cel4 = 0
res = (d1+r1-c2)
another_res = c1+d1-r2
if res <1 or res%2 !=0 or res//2 > 9 or res != another_res:
print(-1)
return
cel1 = res //2
if r1-cel1 >9 or r1-cel1 < 1 or cel1 == r1-cel1:
print(-1)
return
cel2 = r1-cel1
if ... | 7 | PYTHON3 |
r1,r2 = list(map(int,input().split()))
c1,c2 = list(map(int,input().split()))
d1,d2 = list(map(int,input().split()))
res = True
for i in range(1,10):
u = r1-i
v = c1-i
w = d1-i
l = [i,u,v,w]
if min(l)>=1 and len(set(l))==4 and w+v==r2 and u+w==c2 and i+v==c1 and u+i==r1 and u+v==d2 and i+w==d1 and m... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int r, c, d, a, b, R, C, D, A, B;
int main() {
cin >> r >> R >> c >> C >> d >> D;
a = (r + c - D) / 2;
A = (r + C - d) / 2;
b = (R + c - d) / 2;
B = (R + C - D) / 2;
if (a > 0 && b > 0 && A > 0 && B > 0 && a < 10 && A < 10 && b < 10 &&
B < 10 && a != b && ... | 7 | CPP |
R=lambda:map(int,input().split())
r,S=R()
c,C=R()
d,D=R()
A=[(c+d-S)/2,(r+C-d)/2,(S+c-d)/2,(d+C-r)/2]
for i in range(4):
if A[i]!=int(A[i])or A[i]<1or A[i]>9or len(set(A))<4:
print(-1)
exit()
else:A[i]=int(A[i])
print(A[0],A[1])
print(A[2],A[3])
| 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 a = (d1 + c1 - r2) / 2;
int b = (d2 + c2 - r2) / 2;
int c = c1 - a;
int d = c2 - b;
int x = 0;
if (a + b == r1) x++;
if (c + d == r2) x++;
if (a + c == c1) x++;
if (b... | 7 | CPP |
r=list(map(int,input().split()))
c=list(map(int,input().split()))
d=list(map(int,input().split()))
X=0
for i in range(1,10):
ans1=[0,0]
ans2=[0,0]
if i<=d[0] and i<=r[0] and i<=c[0]:
ans1[0]=i
ans2[1]=d[0]-ans1[0]
ans1[1]=abs(r[0]-ans1[0])
if ans1[1]+ans2[1]==c[1]:
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int maxn = 100005;
int a[4];
bool vis[10];
int r1, r2, c1, c2, d1, d2;
bool check() {
if (r1 != a[0] + a[1]) return 0;
if (r2 != a[2] + a[3]) return 0;
if (c1 != a[0] + a[2]) return 0;
if (c2 != a[1] + a[3]) return 0;
if (d1 != a[0] ... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
long long cnt = 0;
for (long long i = 1; i < 10; i++) {
for (long long j = 1; j < 10; j++) {
for (long long k = 1; k < 10; k++) {
for (long long l = 1; l < 10; ... | 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 = (d1 + c1 - r2) / 2;
b = r1 - a;
c = c1 - a;
d = c2 - b;
if (a != b && a != c && a != d && b != c && b != d && c != d && a <= 9 &&
b <= 9 && c <= 9 && ... | 7 | CPP |
"""
βββ βββββββ βββ βββββββ βββββββ βββ ββββββ
βββββββββββββββ βββββββββββββββββββββββββββββ
ββββββ ββββββ ββββββββββββββββββββββββββββ
ββββββ ββββββ βββββββ βββββββββ βββ βββββββ
βββββββββββββββ βββββββββββββββββ βββ βββββββ
βββ βββββββ βββ ββββββββ βββββββ βββ ββββββ
βββββββ ββββββ βββ... | 7 | PYTHON3 |
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
ans = []
a = (r1+c1-d2)//2
ans.append(a)
b = r1 - a
ans.append(b)
c = c1 - a
ans.append(c)
d = d1 - a
ans.append(d)
ans = list(set(ans))
if(len(ans)<4):
print(-1)
elif(ans[3]>9):
print(-1)
elif(a*b*c*d <=0):
... | 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):
for k in range(1,10):
for l in range(1,10):
if i!=j and i!=k and i!=l and j!=k and j!=l and k!=l:
if r1==i+j and r2==k+l an... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int change(int n) {
int p = 1;
while (p * 2 <= n) {
p *= 2;
}
return p;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (int a = 1; a <= 9; ++a) {
for ... | 7 | CPP |
r1 , r2 = map(int, input().split())
c1 , c2 = map(int, input().split())
d1 , d2 = map(int, input().split())
x = 1
for x00 in range(1,10):
for x01 in range(1,10):
if (x00==x01):
continue
for x10 in range(1,10):
if( (x10 == x00) | (x10 == x01) ):
continue
... | 7 | PYTHON3 |
r1,r2=input().split()
c1,c2=input().split()
d1,d2=input().split()
r1=int(r1);r2=int(r2);c1=int(c1);c2=int(c2);d1=int(d1);d2=int(d2)
a=[[0 for i in range(2)]for j in range(2)]
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... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
long long num1, num2, num3, num4;
int f = 0;
for (num1 = 1; num1 <= 9; num1++) {
for (num2 = 1; num2 <= 9; num2++) {
if (num2 == num1) continue;
for (num3 = 1; ... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long arr[2][2];
long long r1, r2, c1, c2, d1, d2;
bool check(long long n) {
arr[0][0] = n;
arr[1][1] = d1 - n;
arr[0][1] = c2 - arr[1][1];
arr[1][0] = d2 - arr[0][1];
for (long long i = 0; i < 2; i++) {
for (long long j = 0; j < 2; j++) {
if (arr[i]... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
bool fun(int a) {
if (a > 0 && a < 10)
return true;
else
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int r1, r2, c1, c2, d1, d2;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
int a[4];
a[0] = (r1 + d1 - c2) / 2;
... | 7 | CPP |
import itertools
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
l=list(range(1,10))
c=itertools.permutations(l,4)
f=0
for i in c:
#print(i)
if((i[0]+i[1]==r1) and (i[2]+i[3]==r2) and (i[0]+i[2]==c1) and (i[1]+i[3]==c2) and (i[0]+i[3]==d1) and (i[1]+i[2]==d2)):
... | 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()]
ans=False
for w in range(1,10):
for x in range(1,10):
for y in range(1,10):
for z in range(1,10):
if w!=x and w!=y and w!=z and x!=y and x!=z and y!=z:
if r[0]==w+x and r[1]==y+z:
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
long long int r1, r2, c1, c2, d1, d2, first = 0;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
long long int val = r1 + r2 + c1 + c2 + d1 + d2;
if (val % 3 != 0) {
cout << "-1";
exit(0);
}
val /= 3;
long long... | 7 | CPP |
r1,r2 = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())
digits = [i for i in range(1,10)]
n = 9
def good_combo(dig1,dig2,dig3,dig4):
row1 = (r1 == dig1 + dig2)
row2 = (r2 == dig3 + dig4)
col1 = (c1 == dig1 + dig3)
col2 = (c2 == dig2 + dig4)
diag1 = (d1 == ... | 7 | PYTHON3 |
r1, r2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
x1 = (c1 + d2 - r1)
if x1 % 2 == 1:
print(-1)
else:
x = x1 // 2
y = r2 - x
v = d1 - y
w = r1 - v
daf = [x, y, v, w]
set_gem = {1, 2, 3, 4, 5, 6, 7, 8, 9}
flag = True
for gem ... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, k, l, r1, r2, c1, c2, d1, d2, a, b, c, d;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
bool ch = false;
for (i = 1; i <= 9; i++) {
for (j = 1; j <= 9; j++) {
for (k = 1; k <= 9; k++) {
for (l = 1; l <= 9; l++) {
a = i;
... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long tt, a1, a2 = 1000000000000, a3, a4, a5, a6, a7, a8, a9, ez1, ans, n,
m, k, sum;
int ul, ur, dl, dr;
string s, s1, s2, s3;
int flag[30];
bool omm(const pair<int, int> &a, const pair<int, int> &b) {
return (a.second < b.second);
}
void input() {
... | 7 | CPP |
#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;
for (int i = 1; i < 10; i++) {
a = i;
b = r1 - i;
if (c1 - a == d2 - b)
c = c1 - a;
else
continue;
if (r2 - c == d1 - a && d1 - a == c2 - b) {... | 7 | CPP |
inp1=input().split()
inp2=input().split()
inp3=input().split()
r1=int(inp1[0])
r2=int(inp1[1])
c1=int(inp2[0])
c2=int(inp2[1])
d1=int(inp3[0])
d2=int(inp3[1])
flag=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==r... | 7 | PYTHON3 |
I=lambda:map(int,input().split())
R=list(range(1,10))
P=print
q,w=I()
e,r=I()
t,y=I()
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==q and c+d==w and a+c==e and b+d==r and a+d==t and b+c==y]
if z:z=z[0];P(z[0],z[1]);P(z[2],z[3])
else:P(-1) | 7 | PYTHON3 |
r1,r2 = map(int, input().split())
c1,c2 = map(int, input().split())
d1,d2 = map(int, input().split())
done = 0
for a1 in range(1,10):
a2 = r1 - a1
if a2 < 1 or a2>9 or a2== a1:
continue
a3 = c1 - a1
if a3 < 1 or a3>9 or a3 == a1 or a3==a2:
continue
a4 = c2 - a2
if a4 < 1 or a4>9 or a4==a1 or a4 == a... | 7 | PYTHON3 |
import sys
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):
for k in range(1,10):
for l in range(1,10):
if(i+j==r1 and i+k==c1 and k+l==r2 and j+l==c2 and i+l==d1 and j+k==d2):
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int x0, x1, y0, y1;
int in1, in2, in3, in4, in5, in6;
scanf("%d%d%d%d%d%d", &in1, &in2, &in3, &in4, &in5, &in6);
x0 = (in3 + in5 - in2) / 2;
x1 = in3 - x0;
y0 = in1 - x0;
y1 = in5 - x0;
if (x0 <= 0 || x1 <= 0 || y0 <= 0 || y1 <= 0) {
printf(... | 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()]
count=0
for i in range(1,10):
if count==1:
break
a=i
for j in range(1,10):
if count==1:
break
b=j
for k in range(1,10):
if ... | 7 | PYTHON3 |
l1, l2 = map(int, input().split())
c1, c2 = map(int, input().split())
d1, d2 = map(int, input().split())
def validar(box):
if box[0] + box[1] == l1 \
and box[2] + box[3] == l2 \
and box[0] + box[2] == c1 \
and box[1] + box[3] == c2 \
and box[0] + box[3] == d1 \
and box[1] + box[2] == d2:
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const double PI = acos(-1.0);
const long long mod = 1e18;
const int maxn = 100000 + 5;
const int N = 10000 + 5;
int r1, r2, c1, c2, d1, d2;
int x, y, z, w;
int infer(int n) {
if (n > 0 && n < 10) return 1;
return 0;
}
int ck(int a, int b, int c,... | 7 | CPP |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
a=(r1+c1-d2)//2
b=c1-a
c=r1-a
d=d1-a
l={a,b,c,d}
if len(l)<4 or min(l)<1 or max(l)>9 or b+d!=r2 or a+d!=d1 or c+d!=c2:
print(-1)
else:
print(a,c)
print(b,d) | 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=c2-b
if a+d==d1 and b+c==d2 and a+b==r1 and c+d==r2 and a+c==c1 and b+d==c2 and len(set([a,b,c,d]))==4 and len(set([a,b,c,d]))==4 and max(a,b,c,d)<10 and min(a,b,c,d)>0:
print(a,b)
print(... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[10];
for (int i = 0; i < 6; i++) scanf("%d", &a[i]);
bool f = 0;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
if (j == i) continue;
for (int k = 1; k <= 9; k++) {
if (k == i || k == j) continue;
for... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int r1, r2, c1, c2, d1, d2;
void fun() {
int val1, val2, val3, val4;
for (int i = 1; i < 10; i++) {
val1 = i;
val2 = r1 - val1;
val3 = c1 - val1;
val4 = c2 - val2;
if (val1 == val2 || val1 == val3 || val1 == val4 || val2 == val3 ||
val3 == va... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int c1, c2, d1, d2, r1, r2, i, j, k, l, f = 0;
cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
for (i = 1; i < 10; i++) {
for (j = 1; j < 10; j++) {
if (j != i)
for (k = 1; k < 10; k++) {
if (k != j && k != i)
fo... | 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int w, x, y, z, a, b, c1, c2, d1, d2;
cin >> a >> b;
cin >> c1 >> c2;
cin >> d1 >> d2;
y = (c2 + d1 - a) / 2;
z = b - y;
w = c2 - y;
x = c1 - z;
if (w == x || w == y || w == z || x == y || x == z || y == z || w < 1 ||
x < 1 || y < 1 || z... | 7 | CPP |
R = list(map(int, input().split()))
C = list(map(int, input().split()))
D = list(map(int, input().split()))
X = [(D[0] + C[0] - R[1]) // 2, (R[0] + C[1] - D[0]) // 2]
Y = [(D[1] + C[0] - R[0]) // 2, (R[1] + C[1] - D[1]) // 2]
if len(set(X + Y)) != 4 or any([True for i in X + Y if i>9 or i<=0]):
print(-1)
else:
... | 7 | PYTHON3 |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
import sys
if (r1+d1-c2)%2==1:
print(-1)
sys.exit()
else :
a=(r1+d1-c2)//2
b=r1-a
d=d1-a
c=r2-d
l1=[a,b,c,d]
if a<=0 or b<=0 or c<=0 or d<=0 or a>9 or b>9 or c>9 or d>9 or(a+b)!=r1 or (c+d)!=r2 o... | 7 | PYTHON3 |
r1,r2=map(int,input().split())
c1,c2=map(int,input().split())
d1,d2=map(int,input().split())
c=((c1-d1)+r2)//2
b=((r1-c1)+d2)//2
a=r1-b
d=d1-a
e={a,b,c,d}
if len(e)==4 and 10>a>0 and 10>b>0 and 10>c>0 and 10>d>0:
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)
... | 7 | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.