Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.*; public class Div2A143 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r1 = sc.nextInt(); int r2 = sc.nextInt(); sc.nextLine(); int c1 = sc.nextInt(); int c2 = sc.nextInt(); sc.nextLine(); int d1 =...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int r1=in.nextInt(),r2=in.nextInt(),c1=in.nextInt(),c2=in.nextInt(),d1=in.nextInt(),d2=in.nextInt(); int x2=(d2-c1+r1)/2; if(2*x2 != (d2-c1+r1)){ ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
def arr_inp(): return [int(x) for x in input().split()] r, c, d = [arr_inp() for i in range(3)] C=((c[0]-d[0]+r[1])/2) if(C!=int(C)): exit(print(-1)) C=int(C) D=r[1]-C A=d[0]-D B=r[0]-A arr=[A,B,C,D] if(min(arr)<1 or max(arr)>9 or A==B or A==C or A==D or B==C or B==D or C==D ): exit(print(-1)) print(A,B) ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
from functools import reduce 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: ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 && ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class R102A { /** * @param args */ public static void main(String[] args) { int[] sums = readInts(); int i,j = 0,k = 0,l = 0; boolean hasSol = false; for(i = 1; i <= 9;...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author alex */ pub...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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;...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.*; public class help{ public static void main(String[] args) { Scanner in=new Scanner(System.in); int r1=in.nextInt(); int r2=in.nextInt(); int c1=in.nextInt(); int c2=in.nextInt(); int d1=in.nextInt(); int d2=in.nextInt(); int d=(c2+r2-d2)/2; int a=d1-d; int c=r2-d; int b=d2-c;...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
mp = lambda: map(int, raw_input().split()) r1, r2 = mp() c1, c2 = mp() d1, d2 = mp() b = -1 f = False for a in range(1, 10): b = r1-a c = c1-a d = d1-a if c + d == r2 and c + b == d2 and b + d == c2 and len(set(range(1, 10)) & set([a, b, c, d]))==4: print a, b print c, d exit() p...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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,...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
# Строки r1, r2 = map(int, input().split()) # Столбцы c1, c2 = map(int, input().split()) # Диагонали d1, d2 = map(int, input().split()) # x a -- уникальные # b c status = False for x in range(1, 10): a = r1 - x c = c2 - a b = r2 - c count = 0 if len(set([x, a, b, c])) == 4: count += 1 if a in range(1, 10...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; /** * * @author Labing Dell */ public class E { static int n1 = 0; static int n2 = 0; static int n3 = 0; static int n4 = 0; p...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
r1, r2 = map(int, raw_input().split()) c1, c2 = map(int, raw_input().split()) d1, d2 = map(int, raw_input().split()) 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 a+b==r1 and a+c==c1 and b+d==c2 and c+d==r2 and a+d==d1 and b+c==d2 ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
from itertools import * def solve(r1,r2,c1,c2,d1,d2): for choice in combinations(xrange(1,10),4): for a,b,c,d in permutations(choice): if a+b==r1 and a+c==c1 and a+d==d1: if b+c==d2 and b+d==c2 and c+d==r2: print a,b print c,d return print -1 r1, r2 = map(int, raw_i...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
import sys import traceback try: r1,r2 = eval('[' + ','.join(sys.stdin.readline().strip('\n\r ').split()) + ']') c1,c2 = eval('[' + ','.join(sys.stdin.readline().strip('\n\r ').split()) + ']') d1,d2 = eval('[' + ','.join(sys.stdin.readline().strip('\n\r ').split()) + ']') if r1>2 and r2>2 and c1>2 and c2>...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.BufferedInputStream; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner input = new Scanner(new BufferedInputStream(System.in)); while(input.hasNext()) { int r1 = input.nextInt(); int r2 = input.nextInt(); int c1 = input.nextInt(); int c2 = i...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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]...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.*; import java.io.*; import java.awt.Point; import java.math.BigDecimal; import java.math.BigInteger; import static java.lang.Math.*; // Solution is at the bottom of code public class A implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.Scanner; public class C102_A_Vanessa { static Scanner in = new Scanner ( System.in); public static void main(String[] args) { // TODO Auto-generated method stub int[] l= new int[4]; int[] ind = new int[6]; boolean check=true; int i,j; for ( i=0;i<2;i++){ ind[i]= in.nextInt(); ind[4...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.Integer.parseInt; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamRea...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
r1, r2 = map(int, raw_input().strip().split()) c1, c2 = map(int, raw_input().strip().split()) d1, d2 = map(int, raw_input().strip().split()) ij = [] hf = [] for i in range(1,10): for j in range(1,10): for h in range(1,10): for f in range(1,10): if i!=j and i!=h and j!=f and j!=h ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc=new Sc...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r1,r2=map(int,input().split()) c1,c2=map(int,input().split()) d1,d2=map(int,input().split()) flag=0 for i in range(1,10): l=[] x1=i y1=r1-x1 x2=c1-x1 y2=c2-y1 if(0<y1<10 and 0<x2<10 and 0<y2<10 and d1==x1+y2 and d2==x2+y1 and y2==r2-x2): l.append(x1) l.append(y2) l.appe...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.Scanner; import java.util.Arrays; import java.util.*; import java.math.*; import java.io.*; public class Main { public static void main ( String args[] ) { Scanner s = new Scanner(System.in); int r1 = s.nextInt(); int r2 = s.nextInt(); int c1 = s.nextInt(); int c2 = s.nextIn...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
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 < 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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 +...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r1, r2 = map(int, input().split()) c1, c2 = map(int, input().split()) d1, d2 = map(int, input().split()) found = False for a in range(1,10): for b in range(1,10): if b != a: for c in range(1,10): if c != b and c != a: for d in range(1,10): ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
r1, r2 = map(int, raw_input().split()) c1, c2 = map(int, raw_input().split()) d1, d2 = map(int, raw_input().split()) f = True for x11 in range(1, 10): for x12 in range(1, 10): for x21 in range(1, 10): for x22 in range(1, 10): if x11 + x21 == c1: if x12 + x22 ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
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()] x2 = (c2 + r1 - d1)//2 x1 = r1 - x2 y1 = d2 - x2 y2 = c2 - x2 if 1 <= x1 <= 9 and 1 <= x2 <= 9 and 1 <= y1 <= 9 and 1 <= y2 <= 9 and x1 != x2 and y1 != y2 and x1 != y1 and x1 != y2 and x...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 ==...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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;...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 && ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
r1, r2 = map(int, raw_input().split()) c1, c2 = map(int, raw_input().split()) d1, d2 = map(int, raw_input().split()) t = False for i in range(1, 10): for j in range(1, 10): for c in range(1, 10): for d in range(1, 10): if i + j == r1 and i + c == c1 and j+c == d2 and i+d == d1 an...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 && ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r1, r2 = list(map(int, input().split())) c1, c2 = list(map(int, input().split())) d1, d2 = list(map(int, input().split())) r1_contender = [] r2_contender = [] for i in range(1, 10): for j in range(1, 10): if i+j == r1 and i != j: r1_contender.append([i,j]) r1_contender.append([j,i])...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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";...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
m=input() n=input() o=input() r1,r2=m.split(" ") c1,c2=n.split(" ") d1,d2=o.split(" ") x=int((int(r1)+int(d1)-int(c2))/2) w=int((int(r2)+int(d2)-int(c2))/2) y=int((int(r1)+int(d2)-int(c1))/2) z=int((int(r2)+int(d1)-int(c1))/2) a=int(r1)+int(r2) b=int(c1)+int(c2) c=int(d1)+int(d2) if x==y or y==z or z==w or w==x or y==...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.PrintWriter; import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } Scanner in; PrintWriter out; boolean check(int a[][]) { return a[0][0] == a[1][1] + a[2][2] && a[0][3] == a[1][2] + a[2][1] && a[2][0] == a[2][1] +...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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;...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
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 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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.*; import java.lang.*; public class A143 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int r1 = in.nextInt(); int r2 = in.nextInt(); int c1 = in.nextInt(); int c2 = in.nextInt(); int d1 = in.nextInt(); int d2 = in.nextInt(); int i=0,j=0,k=0,l=0; i...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
def main(): from itertools import permutations r1, r2, c1, c2, d1, d2 = (int(s) for _ in (1, 2, 3) for s in 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 b + c == d2: print(a, b) ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
// author: Ahmed A.M import java.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); //S1 p1 = new S1(); p1.solve(); //S2 p2 = new S2(); p2.solve(); //S3 p3 = new S3(); p3.solve(); //S4 p4 = new S4(); p4.solv...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
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 max(a,b,c,d)<10 and min(a,b,c,d)>0: print(a,b) print(c,d) else: print(-1) ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.Scanner; import java.io.PrintWriter; import java.util.*; import static java.lang.Math.*; public class A102 { static Scanner in = new Scanner(System.in); static PrintWriter w = new PrintWriter(System.out, true); static int ni() { return in.nextInt(); } static String nl() ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 ==...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r1,r2 = map(int,input().split()) c1,c2 = map(int,input().split()) d1,d2 = map(int,input().split()) c = abs(r1-c1-d2)//2 b = abs(r2-c2-d2)//2 a = abs(r1-b) d = abs(c2-b) res = [a,b,c,d] if a+b != r1 or c+d != r2 or a+d != d1 or b+c != d2: print(-1) else: for i in range(4): if res.count(res[i])>1 or res[i...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
lt=list(input().split()) r1,r2=int(lt[0]),int(lt[1]) lt=list(input().split()) c1,c2=int(lt[0]),int(lt[1]) lt=list(input().split()) d1,d2=int(lt[0]),int(lt[1]) Sw=0 for i00 in range(1,10): for i01 in range(1,10): if i00==i01: continue for i10 in range(1,10): if i10==i01 or i10...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.Scanner; public class HelpVasilisaTheWise2 { private static Scanner in = new Scanner(System.in); public static void main(String[] args) { int[] row = {in.nextInt(), in.nextInt()}; int[] col = {in.nextInt(), in.nextInt()}; int[] dia = {in.nextInt(), in.nextInt()}; ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import static java.lang.Math.*; import static java.lang.System.currentTimeMillis; import static java.lang.System.exit; import static java.lang.System.arraycopy; import static java.util.Arrays.sort; import static java.util.Arrays.binarySearch; import static java.util.Arrays.fill; import java.util.*; import java.io.*; p...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r1, r2 = map(int, input().split()) c1, c2 = map(int, input().split()) d1, d2 = map(int, input().split()) tl, tr ,bl, br = 0,0,0,0 satisfied = False counter = 1 if max(r1,r2,c1,c2,d1,d2) > 8+9: counter = 10 while (counter < 10 and not satisfied): tl = counter tr = r1 - tl bl = c1 - tl br = d1...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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[...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.Arrays; import java.util.Scanner; import static java.lang.Math.*; public class a102 { public static void debug(Object... obs) { System.out.println(Arrays.deepToString(obs)); } public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 == ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
import sys def read2(): return map(int, raw_input().split()) r1, r2 = read2() c1, c2 = read2() d1, d2 = read2() for i in range(1, r1): a, b, c, d = i, r1 - i, c1 - i, d1 - i if a == b or a == c or a == d or b == d or c == d or b == c: continue if any([not (0 < x < 10) for x in (a, b, c, d)]): ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
mp = lambda: map(int, raw_input().split()) r1, r2 = mp() c1, c2 = mp() d1, d2 = mp() b = -1 f = False for a in range(1, 10): b = r1-a c = c1-a d = d1-a if c + d == r2 and c + b == d2 and b + d == c2 and len(set(range(1, 10)) & set([a, b, c, d]))==4: f = True break if not f: print -1 ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
# HELP VASILISA THE WISE 2 # Estacio Pereira, estacio.neto@ccc.ufcg.edu.br # UFCG # INPUT r = raw_input().split() r1, r2 = int(r[0]), int(r[1]) c = raw_input().split() c1, c2 = int(c[0]), int(c[1]) d = raw_input().split() d1, d2 = int(d[0]), int(d[1]) # PROCESS x1 = r1 - 1 x2 = r2 - 1 y1 = 1 y2 = 1 igual1 = False if...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
'''input 13 6 10 9 6 13 ''' r1, r2 = map(int, input().split()) c1, c2 = map(int, input().split()) d1, d2 = map(int, input().split()) r = r1+r2 c = c1+c2 d = d1+d2 sol = True if(r != c or c != d or d != r): print(-1) sol = False if(sol): x = (d1+c1-r2)//2 y = (d2+c2-r2)//2 a = (d2+c1-r1)//2 b ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
import sys import math import itertools def solve(r1, r2, c1, c2, d1, d2): for i in range(1, 10): for j in range(1, 10): for i2 in range(1, 10): for j2 in range(1, 10): if len([i, j, i2, j2]) != len(list(set([i, j, i2, j2]))): continue if (i + j == r1) and...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.*; import java.util.*; import java.math.*; public class Contest102A implements Runnable { public void run() { int r1 = nextInt(); int r2 = nextInt(); int c1= nextInt(); int c2 = nextInt(); int d1 = nextInt(); int d2 = nextInt(); ArrayLis...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.Scanner; public class football { static long time = 0, mp = Integer.MAX_VALUE, k = 0, cnt = 0, edge = 0, no = 0; static int...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r1, r2 = list(map(int, input().split(" "))) c1, c2 = list(map(int, input().split(" "))) d1, d2 = list(map(int, input().split(" "))) ans = [0]*4 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 d1 == i+l and c1 == i + k and c2 == j+l a...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
#!/usr/bin/env python import itertools (r1,r2) = map(int, raw_input().split()) (c1,c2) = map(int, raw_input().split()) (d1,d2) = map(int, raw_input().split()) def check(a,b,c,d): return (r1 == (a+b)) and (r2 == (c+d)) and (c1 == (a+c)) and (c2 == (b+d)) and (d1 == (a+d)) and (d2 == (b+c)) for (a,b,c,d) in iterto...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.*; import java.util.StringTokenizer; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); Strin...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.*; import java.util.*; public class JavaApplication14 { public static void main(String[] args) { FastReader sc = new FastReader(); int r1 = sc.nextInt(), r2 = sc.nextInt(); int c1 = sc.nextInt(), c2 = sc.nextInt(); int d1 = sc.nextInt(), d2 = sc.nextInt(); ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.*; import java.util.*; public class CF102A { private static BufferedReader br; private static StringTokenizer st; private static PrintWriter pw; // private static Timer t = new Timer(); public CF102A() throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = n...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.io.*; import java.math.*; import java.util.*; public class Main { int[] r = new int[2]; int[] c = new int[2]; int[] d = new int[2]; boolean check(int[] ans) { if(ans[2] + ans[3] != r[1]) return false; if(ans[1] + ans[3] != c[1]) return false; if(ans[1] + ans[2] != d[1]) return false; for(in...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 = ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
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 = (d1 - r2 + c1)//2 b = d1 - a c = r1 - a d = c1 - a ans = [a,b,c,d] if len(set(ans))==4: f = 0 for i in ans: if i<=0 or i>9: print("-1") f = 1 ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 > ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
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 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 ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
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 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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
global r1,r2,c1,c2,d1,d2 def valid(x,y,z,w): if x + y != r1: return False if z + w != r2: return False if x + w != d1: return False if y + z != d2: return False if x + z != c1: return False if y + w != c2: return False if x == y: return False if x == z: return False if x == w: return False...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
# https://codeforces.com/problemset/problem/143/A # the main gist is that we find an x = (r1+c1-d2)/2 and then we locate all the other ones # this x. 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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r1 , r2 = map(int, input().split()) c1 , c2 = map(int, input().split()) d1 , d2 = map(int, input().split()) flag = False aa = 0 bb = 0 xx = 0 yy = 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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 /...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python2
L = lambda: map(int,raw_input().split()) r1,r2 = L(); c1,c2 = L(); d1,d2 = L() x = (r1-c1+d2)/2 w = r1 - x y = d2 - x z = c2 - x if any(i<=0 or i>=10 for i in (w,x,y,z)) or len(set([w,x,y,z])) < 4 \ or not (w+x == r1 and y+z == r2 and w+y == c1 and x+z == c2 and w+z == d1 and x+y ==d2): print -1 else: print w...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.*; import java.math.*; public class Euler { public static void main(String[] args) { Scanner in = new Scanner(System.in); int r1 = in.nextInt(); int r2 = in.nextInt(); int c1 = in.nextInt(); int c2 = in.nextInt(); int d1 = in.nextInt(); int d2 = in.nextInt(); ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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++...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.*; import java.io.*; public class Main143A { static PrintWriter out=new PrintWriter(System.out); public static boolean check(int x,int y,int z,int p) { return x!=y&&z!=p&&x!=p&&y!=z&&x!=z&&y!=p; } public static void main(String[] args) throws IOException { Scanner sc=new Sc...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.Scanner; public class P143A_HelpVasilisaTheWise2 { /** * @param args */ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int r1 = scanner.nextInt(); int r2 = scanner.nextInt(); int c1 = scanner.nextInt(); int c2 = scanner.nextInt(); int d1 = scanner...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
java
import java.util.Scanner; public class HelpVasilisaTheWise { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int rowOne = scanner.nextInt(); int rowTwo = scanner.nextInt(); int columnOne = scanner.nextInt(); int columnTwo = scanner.nextInt(...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
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): contin...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r = list(map(int,input().split())) c = list(map(int,input().split())) d = list(map(int,input().split())) b = (d[0]-r[0]+c[1])//2 a = r[1]-b x = c[0]-a y = r[0]-x l = [x,y,a,b] if len(list(dict.fromkeys([x,y,a,b])))==4: if min(l)>0 and max(l)<10: print(x,y,'\n'+str(a),b) else: print(-1) else: print(-1)
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
python3
r1,r2=map(int,input().split()) c1,c2=map(int,input().split()) d1,d2=map(int,input().split()) x,y=(c1-r2+d1)//2,((2*c2)+c1-r2-d1)//2 p,q=(r2+c1-d1)//2,(r2-c1+d1)//2 if p<=0 or q<=0 or x<=0 or y<=0: print("-1") elif x==y or p==q or x==p or x==q or y==q or y==p: print("-1") elif x>9 or y>9 or p>9 or q>9: print...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
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 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 == ...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
cpp
#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 |...
143_A. Help Vasilisa the Wise 2
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha...
{ "input": [ "1 2\n3 4\n5 6\n", "11 10\n13 8\n5 16\n", "3 7\n4 6\n5 5\n", "10 10\n10 10\n10 10\n" ], "output": [ "-1\n", "4 7\n9 1\n", "1 2\n3 4\n", "-1\n" ] }
{ "input": [ "3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10...
CORRECT
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; 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; ...