submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s619929101
p00025
Accepted
while 1: try: a = list(map(int, input().split())) b = list(map(int, input().split())) hit, blow = 0, 0 for i in range(4): if a[i] == b[i]: hit += 1 elif (b[i] in a) == 1: blow += 1 print(hit, blow) except: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s849845895
p00025
Accepted
while True: try: a=list(map(int,input().split())) except:break b=list(map(int,input().split())) h=0 for i,j in zip(a,b):h+=i==j print(h,len(set(a)&set(b))-h)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s072290534
p00025
Accepted
while True : try : a = [int(_) for _ in input().split()] b = [int(_) for _ in input().split()] hit, blow = 0, 0 for _ in range(4) : if a[_] == b[_] : hit += 1 elif b[_] in a : blow += 1 print(hit, blow) except : break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s484539270
p00025
Accepted
while True: try: a= list(map(int,input().split())) b= list(map(int, input().split())) hit = sum([1 for i in range(4) if a[i] == b[i]]) blow = sum([1 for i in range(4) for j in range(4) if i != j and a[i] == b[j]]) print(str(hit) + " " + str(blow)) except: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s071155684
p00025
Accepted
if __name__ == '__main__': while True: try: A = input().split() B = input().split() hit = 0 blow = 0 for i in range(4): if A[i] == B[i]: hit += 1 else: if B[i] in A: blow += 1 print(hit,blow) except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s107453262
p00025
Accepted
while 1: try: h = 0 b = 0 que=input().split(" ") ans=input().split(" ") for i in range(4): for j in range(4): if que[i] == ans[j] and i != j: b = b + 1 if que[i] == ans[j] and i == j: h = h + 1 print(str(h) + " " + str(b)) except:break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s130789932
p00025
Accepted
while 1: try: A = input().split() B = input().split() hit = len([i for i in range(len(A)) if B[i] == A[i]]) blow = len([i for i in range(len(A)) if B[i] in A]) - hit print(str(hit) + " " + str(blow)) except: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s768421828
p00025
Accepted
while True: try: a_set = list(map(int, input().split())) b_set = list(map(int, input().split())) except EOFError: break hit = 0 blow = 0 for i in range(4): if a_set[i] == b_set[i]: hit += 1 for i in range(4): for j in range(4): if a_set[i] == b_set[j] and i != j: blow += 1 print(hit,blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s508341233
p00025
Accepted
import sys alist = [] blist = [] cnt = 0 for line in sys.stdin: if cnt%2 == 0: alist.append(map(int, line.split())) else: blist.append(map(int, line.split())) cnt += 1 for i in range(0, len(alist)): a = alist[i] b = blist[i] hitcount = 0 blowcount = 0 for j in range(0, 4): if a[j] == b[j]: hitcount += 1 for j in range(0, 4): for k in range(0, 4): if a[j] == b[k] and j != k: blowcount += 1 print str(hitcount)+' '+str(blowcount)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s312534796
p00025
Accepted
import sys lines = sys.stdin.readlines() n = len(lines)//2 for i in range(n): hit = 0 blow = 0 cache = {} a = list(map(int, lines[i*2].split())) b = list(map(int, lines[i*2+1].split())) for j in range(len(a)): if a[j] == b[j]: hit += 1 else: cache[a[j]] = True for j in range(len(b)): if cache.get(b[j]): blow += 1 print(hit,blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s118178147
p00025
Accepted
def judge_hit(num1, num2): cnt = 0 for a, b in zip(num1, num2): if a == b: cnt += 1 return cnt def judge_blow(num1, num2, hit): cnt = 0 for b in num2: cnt += (b in num1) return cnt - hit while True: try: A_number = map(int, raw_input().split()) B_number = map(int, raw_input().split()) hit = judge_hit(A_number, B_number) blow = judge_blow(A_number, B_number, hit) print hit, blow except: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s911690255
p00025
Accepted
while(1): try: alist = list(map(int, input().split())) blist = list(map(int, input().split())) except: break hit = 0 blow = 0 for i in range(4): for j in range(4): if alist[i] == blist[j]: if i == j: hit += 1 else: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s703528554
p00025
Accepted
while(1): try: a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] hit = 0 for i,j in zip(a,b): if i == j: hit += 1 sa = set(a) sb = set(b) u = sa & sb blow = len(u) - hit print(hit, blow) except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s023004233
p00025
Accepted
while True: try: a = [x for x in input().split()] b = [x for x in input().split()] hit_count = 0 blow_count = 0 for i in range(4): if a[i] == b[i]: hit_count += 1 elif(b[i] in a): blow_count += 1 print(hit_count, blow_count) except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s218409267
p00025
Accepted
while(1): try: alist = list(map(int, input().split())) blist = list(map(int, input().split())) except: break hit = 0 blow = 0 for i in range(4): for j in range(4): if alist[i] == blist[j]: if i == j: hit += 1 else: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s015347442
p00025
Accepted
def process(A, B): hit, blow = 0, 0 for a, b in zip(A, B): if a == b: hit += 1 elif a in B: blow += 1 return (hit, blow) while True: try: A = input().split() B = input().split() except: break hit, blow = process(A, B) print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s499593817
p00025
Accepted
import sys lines = [] for index, line in enumerate(sys.stdin): line = line.strip() if index%2 == 0: lines.append( [line] ) else: lines[-1].append( line ) #print(lines) lines = iter(lines) for line in lines: i1 = line xs = list(map(int, i1[0].split() )) ys = list(map(int, i1[1].split() )) full_match = 0 spec_match = 0 for x, y in zip(list(xs), list(ys)): #print(x, y, y in xs) if x == y: full_match += 1 elif y in xs: spec_match += 1 print(full_match, spec_match)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s151851696
p00025
Accepted
while(True): try: a = list(map(int, input().split())) b = list(map(int, input().split())) h = [c-d for c,d in zip(a,b)].count(0) v = sum([a.count(d) for d in b]) - h print(h,v) except: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s479583376
p00025
Accepted
import sys def solve(): A = [] B = [] for i, line in enumerate(sys.stdin): t = tuple(map(int, line.split())) if i % 2 == 0: A.append(t) else: B.append(t) for a, b in zip(A, B): hit, blow = 0, 0 for i, bb in enumerate(b): for j, aa in enumerate(a): if bb == aa and i == j: hit += 1 break elif bb == aa and i != j: blow += 1 break print(hit, blow) if __name__ == "__main__": solve()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s113309206
p00025
Accepted
hoge = 0 while True: try: hit = 0 blow = 0 a = map(int, raw_input().split()) b = map(int, raw_input().split()) for i in range(4): try: if a.index(b[i]) == i: hit += 1 else: blow += 1 except ValueError: continue print hit, blow except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s998855208
p00025
Runtime Error
import sys for line in sys.stdin: hit = 0 blow = 0 a_nums = line.split() for i_b, b in input().split(): try: i = a_nums.index(b) if i == i_b: hit += 1 else: blow += 1 except ValueError: continue print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s000692820
p00025
Runtime Error
import sys for i in sys.stdin: arrA,arrB = [],[] s = i.split() for i in s: arrA.append(int(i)) s = input().split() for i in s: arrB.append(int(i)) h,b = 0,0 for i in range(len(arrA)): if arrA[i] == arrB[i]: h += 1 else: if arrB.count(arrA[i]) > 0: b += 1 print(h,b)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s039467687
p00025
Runtime Error
# -*- coding: utf-8 -*- def main(a, b): hit = 0 blow = 0 for a_e, b_e in zip(a, b): if a_e == b_e: hit += 1 elif a_e in b: blow += 1 print(hit, blow, sep=' ') if __name__ == '__main__': while True: a = [int(e) for e in input().split()] b = [int(e) for e in input().split()] if a and b: main(a, b) else: exit()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s430093148
p00025
Runtime Error
while True: a = map(int, raw_input().split()) b = map(int, raw_input().split()) hit = 0 blow = 0 for i in range(4): if(a[i] == b[i]): hit += 1 elif(a[i] in b): blow += 1 print hit, blow
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s815554927
p00025
Runtime Error
while True: a = map(int, raw_input().split(' ')) b = map(int, raw_input().split(' ')) hit = blow = 0 for i in range(4): if(a[i] == b[i]): hit += 1 elif(a[i] in b): blow += 1 print hit, blow
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s992629157
p00025
Runtime Error
while True: try: a = map(int, raw_input().split(' ')) b = map(int, raw_input().split(' ')) hit = blow = 0 for i in range(4): if(a[i] == b[i]): hit += 1 elif(a[i] in b): blow += 1 print hit, blow except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s204349428
p00025
Runtime Error
a=[int(i) for i in input().split()] while True: hit=0 blow=0 try: b=[int(i) for i in input().split()] blow=len(set(a)&set(b)) for i,j for in zip(a,b): if i==j: hit+=1 print(hit,blow-hit) except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s402333650
p00025
Runtime Error
a=[int(i) for i in input().split()] while True: hit=0 blow=0 b=[int(i) for i in input().split()] try: blow=len(set(a)&set(b)) for i,j for in zip(a,b): if i==j: hit+=1 print(hit,blow-hit) except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s939858496
p00025
Runtime Error
while True: hit=0 blow=0 try: a=[int(i) for i in input().split()] b=[int(i) for i in input().split()] blow=len(set(a)&set(b)) for i,j for in zip(a,b): if i==j: hit+=1 print(hit,blow-hit) except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s472388777
p00025
Runtime Error
import sys if __name__ == '__main__': data = [] for line in sys.stdin: data.append([int(x) for x in line.split(' ')]) if len(data) == 2: choice_a = data[0] choice_b = data[1] data = [] #print(choice_a) #print(choice_b) # hit&blow????????? hit = 0 blow = 0 for i, d in enumerate(choice_a): if d in choice_b: if d == choice_b[i]: hit += 1 else: blow += 1 # ???????????¨??? print('{0} {1}'.format(hit, blow))
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s198645196
p00025
Runtime Error
import sys v = iter(sys.stdin.readlines()) for i, j in v, v: a, b = list(i.sprit()), list(j.split()) k = len([n for n in a for m in b if n == m]) l = len(set(a) & set(b)) print(l, k-l)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s734621564
p00025
Runtime Error
while True: l1=list(map(int,input().split())) l2=list(map(int,input().split())) hit=blow=0 for i in l1: for s in l2: if i==s: if l1.index(i)==l2.index(s): hit+=1 else: blow+=1 print(hit,blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s311863231
p00025
Runtime Error
import fileinput for line in fileinput.input(): a = line.split() b = input().split() hit = 0 blow = 0 for i in range(4): for j in range(4): if a[i] == b[j]: if i == j: hit += 1 else: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s115013488
p00025
Runtime Error
import sys import numpy as np def main(): input_line = [] # test_line = ['9 1 8 2', '4 1 5 9', '4 6 8 2', '4 6 3 2'] # for line in test_line: # input_line.append(line.split()) for line in sys.stdin: input_line.append(line.split()) #print(input_line) for i in range(0,len(input_line),2): #hit number arrary1 = np.array(input_line[i], dtype=float) arrary2 = np.array(input_line[i+1], dtype=float) hit_vec = arrary1 - arrary2 hit_list = list(hit_vec) hitnumber = hit_list.count(0.) #print(hit_list.count(0.)) #blow number #get the hit location and remove hit_loc = [i for i,x in enumerate(hit_list) if x == 0] blow_vec1 = np.delete(arrary1, hit_loc) blow_vec2 = np.delete(arrary2, hit_loc) blownumber = len(set(blow_vec1).intersection(blow_vec2)) #print(len(set(blow_vec1).intersection(blow_vec2))) print(hitnumber,blownumber) if __name__ == '__main__': main()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s540226221
p00025
Runtime Error
import sys e=iter(map(lambda a:a.split(),sys.stdin)) for a,b in zip(e,e): h=0;for s,t in zip(a,b):h+=s==t print(h,4-len(set(a)-set(b))-h)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s970361845
p00025
Runtime Error
import sys e=iter(sys.stdin) for a,b in zip(e,e): a,b=a.split(),b.split() for s,t in zip(a,b):h+=s==t print(h,4-len(set(a)-set(b))-h)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s513603855
p00025
Runtime Error
while 1: hit = blow = 0 try: a = [*map(int,input().split(' '))] except: break b = [*map(int,input().split(' '))] for i in range(len(a)): if a[i] == b[i]: hit += 1 if a[i] == b[i-1]: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s502985271
p00025
Runtime Error
a = [*map(int,input().split(' '))] b = [*map(int,input().split(' '))] for i in range(4): if a[i] == b[i]: hit += 1 if a[i] == b[i-1]: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s956357855
p00025
Runtime Error
hit = blow = 0 a = [*map(int,input().split(' '))] b = [*map(int,input().split(' '))] for i in range(4): if a[i] == b[i]: hit += 1 elif a[i] == b[i-1]: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s043797620
p00025
Runtime Error
a = [*map(int,input().split(' '))] b = [*map(int,input().split(' '))] for i in range(4): if a[i] == b[i]: hit += 1 elif a[i] == b[i-1]: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s840681163
p00025
Runtime Error
while True: hit = 0 blow = 0 a = input().split(' ') b = input().split(' ') for a_, b_ in zip(a, b): if a_ == b_: hit += 1 elif a_ in b: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s449516302
p00025
Runtime Error
while(1): hit = 0 blow = 0 a = input().split(' ') b = input().split(' ') for a_, b_ in zip(a, b): if a_ == b_: hit += 1 elif a_ in b: blow += 1 print(hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s435272858
p00025
Runtime Error
import sys ans = [] for line in sys.stdin: aa = list(map(int,input().split())) bb = list(map(int,input().split())) hit = 0 blow = 0 for one in range(len(aa)): if aa[i] == bb[i]: hit += 1 for one_a in range(len(aa)): ai = aa[one_a] for one_b in range(len(bb)): bi = bb[one_b] if ai== bi and one_a != one_b: blow += 1 one_list = [hit,blow] ans.append(one_list) for i in range(len(ans)): print(str(ans[i][0]) + ' ' + str(ans[i][1]))
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s010852013
p00025
Runtime Error
import sys ans = [] for line in sys.stdin: aa = list(map(int,input().split())) bb = list(map(int,input().split())) hit = 0 blow = 0 for one in range(len(aa)): if aa[i] == bb[i]: hit += 1 for one_a in range(len(aa)): ai = aa[one_a] for one_b in range(len(bb)): bi = bb[one_b] if ai== bi and one_a != one_b: blow += 1 one_list = [hit,blow] ans.append(one_list) for i in range(len(ans)): print(str(ans[i][0]) + ' ' + str(ans[i][1]) + ' ')
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s861371756
p00025
Runtime Error
import sys ans = [] for line in sys.stdin: aa = list(map(int,input().split())) bb = list(map(int,input().split())) hit = 0 blow = 0 for one in range(len(aa)): if aa[i] == bb[i]: hit += 1 for one_a in range(len(aa)): ai = aa[one_a] for one_b in range(len(bb)): bi = bb[one_b] if ai== bi and one_a != one_b: blow += 1 one_list = [hit,blow] ans.append(one_list) for i in range(len(ans)): print(str(ans[i][0]) + ' ' + str(ans[i][1]))
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s512301255
p00025
Runtime Error
#!/usr/bin/env python # coding: utf-8 def hit_and_blow(a, b): hits = 0 blows = 0 for i in xrange(4): if b[i] == a[i]: hits += 1 else: for j in xrange(4): if j == i: continue if b[i] == a[j]: blows += 1 return hits, blows def main(): while 1: try: a = [int(x) for x in raw_input().split(" ")] b = [int(x) for x in raw_input().split(" ")] except EOFError: return print "%d %d" % hit_and_blow(a, b) if __name__ == '__main__': main()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s179462533
p00025
Runtime Error
#!/usr/bin/env python # coding: utf-8 def hit_and_blow(a, b): hits = 0 blows = 0 for i in xrange(4): if b[i] == a[i]: hits += 1 else: for j in xrange(4): if j == i: continue if b[i] == a[j]: blows += 1 return hits, blows def main(): try: a = [int(x) for x in raw_input().split(" ")] b = [int(x) for x in raw_input().split(" ")] except EOFError: return print "%d %d" % hit_and_blow(a, b) main() if __name__ == '__main__': main()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s175869056
p00025
Runtime Error
#!/usr/bin/env python # coding: utf-8 def hit_and_blow(a, b): hits = 0 blows = 0 for i in xrange(4): if b[i] == a[i]: hits += 1 else: for j in xrange(4): if j == i: continue if b[i] == a[j]: blows += 1 return hits, blows def main(): while 1: try: a = [int(x) for x in raw_input().split(" ")] b = [int(x) for x in raw_input().split(" ")] except EOFError: pass print "%d %d" % hit_and_blow(a, b) if __name__ == '__main__': main()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s818730877
p00025
Runtime Error
#!/usr/bin/env python # coding: utf-8 def hit_and_blow(a, b): hits = 0 blows = 0 for i in xrange(4): if b[i] == a[i]: hits += 1 else: for j in xrange(4): if j == i: continue if b[i] == a[j]: blows += 1 return hits, blows def main(): inputs = [] while 1: try: inputs.append([int(x) for x in raw_input().split(" ")]) except EOFError: break print "%d %d" % hit_and_blow(inputs[0], inputs[1]) if __name__ == '__main__': main()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s517265064
p00025
Runtime Error
#!/usr/bin/env python # coding: utf-8 def hit_and_blow(a, b): hits = 0 blows = 0 for i in xrange(4): if b[i] == a[i]: hits += 1 else: for j in xrange(4): if j == i: continue if b[i] == a[j]: blows += 1 return hits, blows def main(): inputs = [] while 1: try: inputs.append([int(x) for x in raw_input().split(" ")]) except EOFError: break quads = [] for quad in inputs: quads.append(quad) if quads.__len__() == 2: print "%d %d" % hit_and_blow(*quads) quads = [] if __name__ == '__main__': main()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s243297009
p00025
Runtime Error
#!/usr/bin/env python # coding: utf-8 def hit_and_blow(a, b): hits = 0 blows = 0 for i in xrange(4): if b[i] == a[i]: hits += 1 else: for j in xrange(4): if j == i: continue if b[i] == a[j]: blows += 1 return hits, blows def main(): while 1: try: a = [int(x) for x in raw_input().split(" ")] except EOFError: break b = [int(x) for x in raw_input().split(" ")] print "%d %d" % hit_and_blow(a, b) if __name__ == '__main__': main()
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s016175755
p00025
Runtime Error
while True: a=map(int,raw_input().split()) if not a:break b=map(int,raw_input().split()) hit,blow=0,0 for i in range(4): if a[i]==b[i]:hit+=1 if a[i] in b :blow+=1 print hit,blow-hit
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s731079671
p00025
Runtime Error
while True: try: listA = map(int,raw_input().split(' ')) listB = map(int,raw_input().split(' ')) hit=0 blw=0 for tB in listB: if (tB in listA) and (listB.index(tB) == listA.index(tB)): hit += 1 elif (tB in listA) and (listB.index(tB) != listA.index(tB)): blw += 1 print hit,blw except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s648126187
p00025
Runtime Error
if __name__ == "__main__": while True: try: hit = 0 br = 0 a = map(int,raw_input().split(' ')) b = map(int,raw_input().split(' ')) for i in range(4): for j in range(4): if a[i] == b[j]: print a[i],b[j] hit += 1 elif a[i] == b[j]: br += 1 print hit,br except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s049097663
p00025
Runtime Error
while True: try: hit = 0 br = 0 a = map(int,raw_input().split(' ')) b = map(int,raw_input().split(' ')) for i in range(4): for j in range(4): if a[i] == b[j]: print a[i],b[j] hit += 1 elif a[i] == b[j]: br += 1 print hit,br except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s149719047
p00025
Runtime Error
if __name__ == "__main__": while True: try: hit = 0 br = 0 a = map(int,raw_input().split(' ')) b = map(int,raw_input().split(' ')) for i in range(4): for j in range(4): if a[i] == b[j]: hit += 1 elif a[i] == b[j]: br += 1 print hit,br except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s911340863
p00025
Runtime Error
while True: try: hit = 0 br = 0 a = map(int,raw_input().split(' ')) b = map(int,raw_input().split(' ')) for i in range(4): for j in range(4): if a[i] == b[j]: if i == j: hit += 1 else: br += 1 print hit,br except EOFError: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s071707942
p00025
Runtime Error
import sys for lineCnt, line in enumerate(sys.stdin): if lineCnt % 2 == 0: a = map(int, line.split(' ')) continue else: b = map(int, line.split(' ')) hit = blow = 0 for i, na in enumerate(a): if b[i] == na: hit += 1 elif na in b: blow += 1 print '%d %d' % (hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s817161690
p00025
Runtime Error
import sys for lineCnt, line in enumerate(sys.stdin): if lineCnt % 2 == 0: a = map(int, line.split(' ')) continue else: b = map(int, line.split(' ')) hit, blow = 0,0 for i, na in enumerate(a): if b[i] == na: hit += 1 elif na in b: blow += 1 print '%d %d' % (hit, blow)
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers included (but different place) in the numbers <i>A</i> imagined (Blow)</li> </ul> <p> For example, if <i>A</i> imagined numbers: </p> <pre> 9 1 8 2 </pre> <p> and <i>B</i> chose: </p> <pre> 4 1 5 9 </pre> <p> <i>A</i> should say 1 Hit and 1 Blow. </p> <p> Write a program which reads four numbers <i>A</i> imagined and four numbers <i>B</i> chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. </p> <H2>Input</H2> <p> The input consists of multiple datasets. Each dataset set consists of: </p> <pre> <var>a<sub>1</sub></var> <var>a<sub>2</sub></var> <var>a<sub>3</sub></var> <var>a<sub>4</sub></var> <var>b<sub>1</sub></var> <var>b<sub>2</sub></var> <var>b<sub>3</sub></var> <var>b<sub>4</sub></var> </pre> <p> , where <var>a<sub>i</sub></var> (0 &le; <var>a<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>A</i> imagined and <var>b<sub>i</sub></var> (0 &le; <var>b<sub>i</sub></var> &le; 9) is <var>i</var>-th number <i>B</i> chose. </p> <p> The input ends with EOF. The number of datasets is less than or equal to 50. </P> <H2>Output</H2> <p> For each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space. </p> <H2>Sample Input</H2> <pre> 9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2 </pre> <H2>Output for the Sample Input</H2> <pre> 1 1 3 0 </pre>
s692785629
p00026
Wrong Answer
#!/usr/bin/python paper = [0 for i in range(100)] white_points = None deep_points = None def small(x, y): p = [[x, y]] for i, j in zip([-1, 0, 1, 0], [0, -1, 0, 1]): p.append([x + i, y + j]) return p def middle(x, y): p = small(x, y) for i, j in zip([1, -1] * 2, [1, 1, -1, -1]): p.append([x + i, y + j]) return p def big(x, y): p = middle(x, y) for i, j in zip([-2, 0, 2, 0], [0, -2, 0, 2]): p.append([x + i, y + j]) return p while True: try: x, y, size = map(int, input().split(',')) except: print(paper.count(0)) print(max(paper)) break if size == 1: bp = small(x, y) elif size == 2: bp = middle(x, y) elif size == 3: bp = big(x, y) for p in bp: if not 0 <= p[0] * 10 + p[1] <= 99: continue paper[p[0] * 10 + p[1]] += 1
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s165128973
p00026
Wrong Answer
paper = [0 for i in range(100)] white_points = None deep_points = None def small(x, y): p = [[x, y]] for i, j in zip([-1, 0, 1, 0], [0, -1, 0, 1]): p.append([x + i, y + j]) return p def middle(x, y): p = small(x, y) for i, j in zip([1, -1, 1, -1], [1, 1, -1, -1]): p.append([x + i, y + j]) return p def big(x, y): p = middle(x, y) for i, j in zip([-2, 0, 2, 0], [0, -2, 0, 2]): p.append([x + i, y + j]) return p while True: try: x, y, size = map(int, input().split(',')) except: print(paper.count(0)) print(max(paper)) break if size == 1: bp = small(x, y) elif size == 2: bp = middle(x, y) elif size == 3: bp = big(x, y) for p in bp: if not 0 <= p[1] * 10 + p[0] <= 99: continue paper[p[1] * 10 + p[0]] += 1
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s077375638
p00026
Wrong Answer
# -*- coding: utf-8 -*- def density_adder(array,x,y,delta_list): for k in delta_list: dx,dy = k cell_num = 10*(x-dx) + (y-dy) if 0 <= cell_num <100: array[10*x + y][2] += 1 array = [[i,j,0] for i in range(10) for j in range(10)] input_list = [] while True: try: x,y,size = map(int,raw_input().split(",")) input_list.append((x,y,size)) except: break small_delta_ls = [(0,0),(-1,0),(1,0),(0,-1),(0,1)] medium_delta_ls = small_delta_ls + [(1,1),(1,-1),(-1,1),(-1,-1)] large_delta_ls = medium_delta_ls + [(-2,0),(2,0),(0,2),(0,-2)] for j in input_list: x,y,size = j if size == 1: # Small density_adder(array,x,y,small_delta_ls) elif size == 2: # Medium density_adder(array,x,y,medium_delta_ls) elif size ==3 : # Large density_adder(array,x,y,large_delta_ls) ink_zero = 0 densest = 0 for k in xrange(100): if array[k][2]==0: ink_zero +=1 if array[k][2] > densest: densest = array[k][2] print ink_zero print densest
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s499099132
p00026
Wrong Answer
# -*- coding: utf-8 -*- def density_adder(array,x,y,delta_list): for k in delta_list: dx,dy = k cell_num = 10*(x-dx) + (y-dy) if 0 <= cell_num <100: array[cell_num][2] += 1 array = [[i,j,0] for i in range(10) for j in range(10)] input_list = [] while True: try: x,y,size = map(int,raw_input().split(",")) input_list.append((x,y,size)) except: break small_delta_ls = [(0,0),(-1,0),(1,0),(0,-1),(0,1)] medium_delta_ls = small_delta_ls + [(1,1),(1,-1),(-1,1),(-1,-1)] large_delta_ls = medium_delta_ls + [(-2,0),(2,0),(0,2),(0,-2)] for j in input_list: x,y,size = j if size == 1: # Small density_adder(array,x,y,small_delta_ls) elif size == 2: # Medium density_adder(array,x,y,medium_delta_ls) elif size ==3 : # Large density_adder(array,x,y,large_delta_ls) ink_zero = 0 densest = 0 for k in xrange(100): if array[k][2]==0: ink_zero +=1 if array[k][2] > densest: densest = array[k][2] print ink_zero print densest
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s803941816
p00026
Wrong Answer
# -*- coding: utf-8 -*- def density_adder(array,x,y,delta_list): for k in delta_list: dx,dy = k cell_num = 10*(x-dx) + (y-dy) if 0 <= cell_num <100: array[cell_num][2] += 1 return array array = [[i,j,0] for i in range(10) for j in range(10)] input_list = [] while True: try: x,y,size = map(int,raw_input().split(",")) input_list.append((x,y,size)) except: break small_delta_ls = [(0,0),(-1,0),(1,0),(0,-1),(0,1)] medium_delta_ls = small_delta_ls + [(1,1),(1,-1),(-1,1),(-1,-1)] large_delta_ls = medium_delta_ls + [(-2,0),(2,0),(0,2),(0,-2)] for j in input_list: x,y,size = j if size == 1: # Small density_adder(array,x,y,small_delta_ls) elif size == 2: # Medium density_adder(array,x,y,medium_delta_ls) elif size ==3 : # Large density_adder(array,x,y,large_delta_ls) ink_zero = 0 densest = 0 for k in range(100): if array[k][2]==0: ink_zero +=1 if array[k][2] > densest: densest = array[k][2] print ink_zero print densest
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s925590194
p00026
Wrong Answer
p = [[0 for a in range(10)] for b in range(10)] def smallink(x,y): return [(x+i,y+j) for i in range(-1,2,1) for j in range(-1,2,1)\ if abs(i)+abs(j)<=1 and x+i>=0 and y+j>=0] def ink(x,y): return [(x+i,y+j) for i in range(-1,2,1) for j in range(-1,2,1)\ if x+i>=0 and y+j>=0] def bigink(x,y): return [(x+i,y+j) for i in range(-2,3,1) for j in range(-2,3,1)\ if abs(i)+abs(j)<=2 and x+i>=0 and y+j>=0] while True: try: x,y,size=map(int,raw_input().split(",")) if size==1: L=smallink(x,y) elif size==2: L=ink(x,y) else: L=bigink(x,y) while len(L)!=0: point=L.pop(0) p[point[0]][point[1]]+=1 except: break count=0 max=0 for i in range(10): for j in range(10): if(p[i][j]>max): max=p[i][j] if(p[i][j]==0): count+=1 print count print max
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s392382500
p00026
Wrong Answer
#encoding=utf-8 import sys ans = 0 par, num = [], [] for i in sys.stdin: num.append(map(int, i.split(","))) for i in xrange(10): par.append([0,0,0,0,0,0,0,0,0,0]) for i in xrange(len(num)): try: par[num[i][1]][num[i][0]] += 1 par[num[i][1] - 1][num[i][0]] += 1 par[num[i][1] + 1][num[i][0]] += 1 par[num[i][1]][num[i][0] - 1] += 1 par[num[i][1]][num[i][0] + 1] += 1 except: pass if num[i][2] == 2 or num[i][2] == 3: try: par[num[i][1] - 1][num[i][0] - 1] += 1 par[num[i][1] - 1][num[i][0] + 1] += 1 par[num[i][1] + 1][num[i][0] - 1] += 1 par[num[i][1] + 1][num[i][0] + 1] += 1 except: pass if num[i][2] == 3: try: par[num[i][1] - 2][num[i][0]] += 1 par[num[i][1] ][num[i][0] - 2] += 1 par[num[i][1] + 2][num[i][0]] += 1 par[num[i][1] ][num[i][0] + 2] += 1 except: pass for i in xrange(10): for j in xrange(10): if par[i][j] == 0: ans += 1 print ans print max(max(par))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s204730493
p00026
Wrong Answer
#encoding=utf-8 import sys ans = 0 par, num = [], [] for i in sys.stdin: num.append(map(int, i.split(","))) for i in xrange(10): par.append([0,0,0,0,0,0,0,0,0,0]) for i in xrange(len(num)): try: par[num[i][1]][num[i][0]] += 1 except: pass try: par[num[i][1] - 1][num[i][0]] += 1 except: pass try: par[num[i][1] + 1][num[i][0]] += 1 except: pass try: par[num[i][1]][num[i][0] - 1] += 1 except: pass try: par[num[i][1]][num[i][0] + 1] += 1 except: pass if num[i][2] == 2 or num[i][2] == 3: try:par[num[i][1] - 1][num[i][0] - 1] += 1 except: pass try: par[num[i][1] - 1][num[i][0] + 1] += 1 except: pass try: par[num[i][1] + 1][num[i][0] - 1] += 1 except: pass try: par[num[i][1] + 1][num[i][0] + 1] += 1 except: pass if num[i][2] == 3: try: par[num[i][1] - 2][num[i][0]] += 1 except: pass try: par[num[i][1] ][num[i][0] - 2] += 1 except: pass try: par[num[i][1] + 2][num[i][0]] += 1 except: pass try: par[num[i][1] ][num[i][0] + 2] += 1 except: pass for i in xrange(10): for j in xrange(10): if par[i][j] == 0: ans += 1 print ans print max(max(par))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s081227749
p00026
Wrong Answer
import sys class Paper: def __init__(self): self.paper = [[0 for x in range(10)] for y in range(10)] def white_space(self): s = 0 for x in range(10): for y in range(10): if self.paper[x][y] == 0: s += 1 return s def most_dark(self): s = 0 for x in range(10): for y in range(10): if self.paper[x][y] > s: s = self.paper[x][y] return s def drop(self, x, y, size): r = [] if size == 1: r.append((x,y)) r.append((x-1,y)) r.append((x+1,y)) r.append((x,y-1)) r.append((x,y+1)) elif size == 2: r = [(i,j) for i in range(x-1, x+2) for j in range(y-1, y+2)] elif size == 3: r = [(i,j) for i in range(x-1, x+2) for j in range(y-1, y+2)] r.append((x-2, y)) r.append((x+2, y)) r.append((x, y-2)) r.append((x, y+2)) else: pass r = filter(self.out_of_paper, r) try: for p in r: self.paper[p[0]][p[1]] += 1 except: pass return self def out_of_paper(self, p): if 0 <= p[0] < 10 and 0 <= p[1] < 10: return True else: return False paper = Paper() for line in sys.stdin: (x, y, size) = tuple(map(int, line.split(","))) paper.drop(x, y, size) print paper.white_space() print paper.most_dark()
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s101257371
p00026
Wrong Answer
# -*- coding: utf-8 -*- import sys def small_inc(x, y, cells): cells[x][y] += 1 if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if y < MAPSIZE-1: cells[x][y+1] += 1 def medium_inc(x, y, cells): if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y-1] += 1 if x < MAPSIZE-1: cells[x+1][y-1] += 1 cells[x][y] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if y < MAPSIZE-1: cells[x][y-1] += 1 if x > 0: cells[x-1][y+1] += 1 if x < MAPSIZE-1: cells[x+1][y+1] += 1 def large_inc(x, y, cells): if y > 1: cells[x][y-2] += 1 if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y-1] += 1 if x < MAPSIZE-1: cells[x+1][y-1] += 1 cells[x][y] += 1 if x > 1: cells[x-2][y] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if x < MAPSIZE-2: cells[x+2][y] += 1 if y < MAPSIZE-1: cells[x][y-1] += 1 if x > 0: cells[x-1][y+1] += 1 if x < MAPSIZE-1: cells[x+1][y+1] += 1 if y < MAPSIZE-2: cells[x][y+2] += 1 SMALL = 1 MEDIUM = 2 LARGE = 3 MAPSIZE = 10 cells = [[0 for i in range(MAPSIZE)] for j in range(MAPSIZE)] for line in sys.stdin: x , y, size = map(int, line.split(',')) if size == SMALL: small_inc(x, y, cells) elif size == MEDIUM: medium_inc(x, y, cells) elif size == LARGE: large_inc(x, y, cells) count = max_d = 0 for i in range(MAPSIZE): for j in range(MAPSIZE): if cells[i][j] == 0: count += 1 else: max_d = max(max_d, cells[i][j]) print count print max_d
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s610264293
p00026
Wrong Answer
# -*- coding: utf-8 -*- import sys def small_inc(x, y, cells): cells[x][y] += 1 if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if y < MAPSIZE-1: cells[x][y+1] += 1 def medium_inc(x, y, cells): if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y-1] += 1 if x < MAPSIZE-1: cells[x+1][y-1] += 1 cells[x][y] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if y < MAPSIZE-1: cells[x][y+1] += 1 if x > 0: cells[x-1][y+1] += 1 if x < MAPSIZE-1: cells[x+1][y+1] += 1 def large_inc(x, y, cells): if y > 1: cells[x][y-2] += 1 if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y-1] += 1 if x < MAPSIZE-1: cells[x+1][y-1] += 1 cells[x][y] += 1 if x > 1: cells[x-2][y] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if x < MAPSIZE-2: cells[x+2][y] += 1 if y < MAPSIZE-1: cells[x][y+1] += 1 if x > 0: cells[x-1][y+1] += 1 if x < MAPSIZE-1: cells[x+1][y+1] += 1 if y < MAPSIZE-2: cells[x][y+2] += 1 SMALL = 1 MEDIUM = 2 LARGE = 3 MAPSIZE = 10 cells = [[0 for i in range(MAPSIZE)] for j in range(MAPSIZE)] for line in sys.stdin: x , y, size = map(int, line.split(',')) if size == SMALL: small_inc(x, y, cells) elif size == MEDIUM: medium_inc(x, y, cells) elif size == LARGE: large_inc(x, y, cells) count = max_d = 0 for i in range(MAPSIZE): for j in range(MAPSIZE): if cells[i][j] == 0: count += 1 else: max_d = max(max_d, cells[i][j]) for i in range(MAPSIZE): print " ".join(map(str, cells[i])) print count print max_d
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s391579770
p00026
Wrong Answer
d = [[0] * 10 for i in range(10)] def b(x, y): for i in range(x - 2, x + 3): a = 3 - abs(x - i) for a in range(y - a + 1, y + a): if 0 <= i < 10 and 0 <= a < 10: d[a][i] += 1 def m(x, y): for i in range(x - 1, x + 2): for j in range(y - 1, y + 2): if 0 <= i < 10 and 0 <= j < 10: d[j][i] += 1 def s(x, y): r = (1, 0) for i in range(x - 1, x + 2): a = abs(x - i) for j in range(y - r[a], y + r[a] + 1): if 0 <= i < 10 and 0 <= j < 10: d[j][i] += 1 while 1: try: f = (None, s, m, b) x, y, size = list(map(int, input().split(','))) f[size](x, y) except: break r1 = r2 = 0 for i in range(10): for j in range(10): r1 += 1 if d[i][j] == 0 else 0 r2 = max(r2, d[i][j]) print(r1, r2)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s163690300
p00026
Wrong Answer
a = [[0] * 14 for _ in range(14)] while True: try: x, y, s = map(int, input().split(',')) except: break x += 2 y += 2 for d in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]: a[x + d[0]][y + d[1]] += 1 if s >= 2: for d in [(1, 1), (1, -1), (-1, 1), (-1, -1)]: a[x + d[0]][y + d[1]] += 1 if s == 3: for d in [(0, 2), (0, -2), (2, 0), (-2, 0)]: a[x + d[0]][y + d[1]] += 1 print(sum(a[i][2:12].count(0) for i in range(2, 12))) print(max(max(a[i]) for i in range(14))) print(a)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s743554912
p00026
Wrong Answer
a = [[0] * 14 for _ in range(14)] while True: try: x, y, s = map(int, input().split(',')) except: break x += 2 y += 2 for d in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]: a[x + d[0]][y + d[1]] += 1 if s >= 2: for d in [(1, 1), (1, -1), (-1, 1), (-1, -1)]: a[x + d[0]][y + d[1]] += 1 if s == 3: for d in [(0, 2), (0, -2), (2, 0), (-2, 0)]: a[x + d[0]][y + d[1]] += 1 print(sum(a[i][2:12].count(0) for i in range(2, 12))) print(max(max(a[i][2:12]) for i in range(2, 12))) print(a)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s455745204
p00026
Wrong Answer
import sys drops = [None, [(-1,0),(1,0),(0,-1),(0,1)], [(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1)], [(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1),(-2,0),(2,0),(0,-2),(0,2)]] B = [[0 for j in xrange(10)] for i in xrange(10)] for line in sys.stdin: x, y, s = map(int, line.rstrip().split(',')) for dx, dy in drops[s]: nx, ny = x+dx, y+dy if (nx < 0 or nx > 9 or ny < 0 or ny > 9): continue B[ny][nx] += 1 emp, m = 0, 0 for i in xrange(10): for j in xrange(10): if B[i][j] == 0: emp += 1 m = max(m, B[i][j]) print emp print m
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s785580407
p00026
Wrong Answer
import sys drops = [None, [(-1,0),(1,0),(0,-1),(0,1)], [(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1)], [(-1,0),(1,0),(0,-1),(0,1),(-1,1),(-1,-1),(1,-1),(1,1),(-2,0),(2,0),(0,-2),(0,2)]] B = [[0 for j in xrange(10)] for i in xrange(10)] for line in sys.stdin: x, y, s = map(int, line.rstrip().split(',')) for dx, dy in drops[s]: nx, ny = x+dx, y+dy if (0 <= nx <= 9 and 0 <= ny <= 9): B[ny][nx] += 1 emp, m = 0, 0 for i in xrange(10): for j in xrange(10): if B[i][j] == 0: emp += 1 m = max(m, B[i][j]) print emp print m
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s090239443
p00026
Wrong Answer
import sys paper = [[0] * 10 for i in range(10)] for line in sys.stdin: x,y,s = map(int,line.split(',')) for i in range(10): for j in range(10): if s == 1: if abs(i - y) + abs(j - x) <= 1: paper [i] [j] += 1 if s == 2: if abs(i - y) <= 1 and abs(j - x) <= 1: paper [i] [j] += 1 if s == 3: if abs(i - y) + abs(j - x) <= 2: paper [i] [j] += 1 ans = [0,0] for i in range(10): for j in range(10): if paper [i] [j] == 0: ans [0] += 1 if paper [i] [j] > ans [1]: ans [1] = paper [i] [j] print(ans [0],ans [1])
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s570127393
p00026
Wrong Answer
Masu = [] def access(x,y): if x < 0 or y < 0 or x > 9 or y > 9: return Masu[y][x] += 1 for i in range(10): Masu.append([0,0,0,0,0,0,0,0,0,0]) kosu = 0 komax = 0 while True: try: x,y,s = map(int,input().split(",")) if s == 1: for j in range(3): access(y +1 - j,x) access(y,x - 1) access(y,x + 1) elif s == 2: for k in range(3): for l in range(3): access(y + 1 - k,x + 1 -l) elif s == 3: for k in range(3): for l in range(3): access(y + 1 - k,x + 1 -l) access(y - 2,x) access(y + 2,x) access(y,x + 2) access(y,x - 2) print(Masu) except (EOFError,ValueError): for i in range(10): kosu += Masu[i].count(0) for j in range(10): if komax < max(Masu[j]): komax = max(Masu[j]) print(kosu) print(komax) break
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s956045492
p00026
Wrong Answer
board=[[0]*10 for i in range(10)] ink=[[[0,0,0,0,0],[0,0,1,0,0],[0,1,1,1,0],[0,0,1,0,0],[0,0,0,0,0]], [[0,0,0,0,0],[0,1,1,1,0],[0,1,1,1,0],[0,1,1,1,0],[0,0,0,0,0]], [[0,0,1,0,0],[0,1,1,1,0],[1,1,1,1,1],[0,1,1,1,0],[0,0,1,0,0]]] while True: try: x,y,s=map(int,input().split(",")) except: break for i in range(5): for j in range(5): if 0<=i+y-2<=9 and 0<=j+x-2<=9: board[i+y-2][j+x-2]+=ink[s-1][i][j] flat=sum(board,[]) print(flat.count(0)) print(flat.count(max(flat)))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s601139737
p00026
Wrong Answer
paper = [0 for x in range(10) for y in range(10)] while True : try: x, y, ink = [int(_) for _ in input().split(',')] temp = (x - 1) + y * 10 spot = [temp] for _ in 1, 10 : if temp + _ > 0 : spot.append(temp + _) if temp - _ > 0 : spot.append(temp - _) if ink == 2 or ink == 3 : for _ in 9, 11 : if temp + _ > 0 : spot.append(temp + _) if temp - _ > 0 : spot.append(temp - _) if ink == 3 : for _ in 2, 20 : if temp + _ > 0 : spot.append(temp + _) if temp - _ > 0 : spot.append(temp - _) for _ in spot : paper[_] += 1 except : break none = 0 for _ in paper : if _ == 0 : none += 1 print(none, max(paper))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s607459562
p00026
Wrong Answer
paper = [0 for x in range(10) for y in range(10)] while True : try: x, y, ink = [int(_) for _ in input().split(',')] temp = (x - 1) + y * 10 spot = [temp] for _ in 1, 10 : if temp + _ > 0 : spot.append(temp + _) if temp - _ > 0 : spot.append(temp - _) if ink == 2 or ink == 3 : for _ in 9, 11 : if temp + _ > 0 : spot.append(temp + _) if temp - _ > 0 : spot.append(temp - _) if ink == 3 : for _ in 2, 20 : if temp + _ > 0 : spot.append(temp + _) if temp - _ > 0 : spot.append(temp - _) for _ in spot : paper[_] += 1 except : break none = 0 for _ in paper : if _ == 0 : none += 1 print(none) print(max(paper))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s847892407
p00026
Wrong Answer
import sys n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]] n2 = n1 + [[a, b] for a in [-1,1] for b in [-1, 1]] n3 = n2 + [[a*2, b*2] for a, b in n1] mas = [[0]*10 for i in range(10)] for i in sys.stdin: try: x, y, a = list(map(int,i.split(","))) mas[y][x] += 1 for j in eval("n"+str(a)): try: mas[y+j[1]][x+j[0]] += 1 except IndexError: continue except: break print(len([i for x in mas for i in x if not i])) print(max([max(v) for v in mas]))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s200123623
p00026
Wrong Answer
import sys n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]] n2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]] n3 = n2 + [[a*2, b*2] for a, b in n1] mas = [[0]*10 for i in range(10)] for i in sys.stdin: try: x, y, a = list(map(int, i.split(","))) mas[y][x] += 1 for j in eval("n"+str(a)): try: mas[y+j[1]][x+j[0]] += 1 except IndexError: continue except: break print(len([i for x in mas for i in x if not i])) print(max([max(v) for v in mas]))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s932436861
p00026
Wrong Answer
import sys n1 = [[0, 1], [1, 0], [-1, 0], [0, -1]] n2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]] n3 = n2 + [[a*2, b*2] for a, b in n1] mas = [[0]*10 for i in range(10)] for i in sys.stdin: try: x, y, a = list(map(int, i.split(","))) mas[y][x] += 1 for k,l in eval("n"+str(a)): try: if y+l>= 0 and x+k >= 0: mas[y+l][x+k] += 1 except IndexError: continue except ValueError: break print(mas) print(len([i for x in mas for i in x if not i])) print(max([max(v) for v in mas]))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s347239489
p00026
Wrong Answer
t = [[0 for i in range(10)] for j in range(10)] case1 = [(0, 0), (0, -1), (1, 0), (0, 1), (-1, 0)] case2 = [(1, -1), (1, 1), (-1, 1), (-1, -1)] case3 = [(0, -2), (2, 0), (0, 2), (-2, 0)] while True: try: x, y, s = map(int, input().split(',')) except: break for c in [case1, case2, case3][:s]: for _x, _y in c: try: t[x+_x][y+_y] += 1 except IndexError: continue print(sum(1 for l in t for v in l if not v)) print(max(v for l in t for v in l))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s344383441
p00026
Wrong Answer
t = [[0 for i in range(10)] for j in range(10)] case1 = [(0, 0), (0, -1), (1, 0), (0, 1), (-1, 0)] case2 = [(1, -1), (1, 1), (-1, 1), (-1, -1)] case3 = [(0, -2), (2, 0), (0, 2), (-2, 0)] while True: try: x, y, s = map(int, input().split(',')) except: break for c in [case1, case2, case3][:s]: for _x, _y in c: try: t[y+_y][x+_x] += 1 except IndexError: continue print(sum(1 for l in t for v in l if not v)) print(max(v for l in t for v in l))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s663219549
p00026
Wrong Answer
A=[[int(0) for i in range(10)]for j in range(10)] count=0 while 1: try: x,y,s = map(int, input().split(',')) if s==1: for i in range(x-1,x+1): if i>=0 and i<=9: A[i][y]=A[i][y]+1 for i in range(y-1,y+1): if i>=0 and i<=9: A[x][i]=A[x][i]+1 A[x][y]=A[x][y]-1 elif s==2: for i in range(x-1,x+1): for j in range(y-1,y+1): if i>=0 and i<=9 and j>=0 and j<=9: A[i][j]=A[i][j]+1 else: for i in range(x-2,x+2): if i>=0 and i<=9: A[i][y]=A[i][y]+1 for i in range(y-2,y+2): if i>=0 and i<=9: A[x][i]=A[x][i]+1 for i in range(x-1,x+1): if i>=0 and i<=9: A[i][y]=A[i][y]-1 for i in range(y-1,y+1): if i>=0 and i<=9: A[x][i]=A[x][i]-1 for i in range(x-1,x+1): for j in range(y-1,y+1): if i>=0 and i<=9 and j>=0 and j<=9: A[i][j]=A[i][j]+1 except EOFError: break for i in range(10): for j in range(10): if A[i][j]==0: count=count+1 print(count) print(max(A))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s724596557
p00026
Wrong Answer
area = [[0 for i in range(10)] for j in range(10)] while True: try: x, y, s = map(int, input().split(',')) except: break if s == 3: if (0 <= x+2 <= 9) and (0 <= y <= 9): area[x+2][y] += 1 if (0 <= x <= 9) and (0 <= y+2 <= 9): area[x][y+2] += 1 if (0 <= x-2 <= 9) and (0 <= y <= 9): area[x-2][y] += 1 if (0 <= x <= 9) and (0 <= y-2 <= 9): area[x][y-2] += 1 if s >= 2: if (0 <= x+1 <= 9) and (0 <= y+1 <= 9): area[x+1][y+1] += 1 if (0 <= x+1 <= 9) and (0 <= y-1 <= 9): area[x+1][y-1] += 1 if (0 <= x-1 <= 9) and (0 <= y+1 <= 9): area[x-1][y+1] += 1 if (0 <= x-1 <= 9) and (0 <= y-1 <= 9): area[x-1][y-1] += 1 if s >= 1: if (0 <= x+1 <= 9) and (0 <= y <= 9): area[x+1][y] += 1 if (0 <= x <= 9) and (0 <= y+1 <= 9): area[x][y+1] += 1 if (0 <= x-1 <= 9) and (0 <= y <= 9): area[x-1][y] += 1 if (0 <= x <= 9) and (0 <= y-1 <= 9): area[x][y-1] += 1 area[x][y] += 1 print(area) max = 0 cnt = 0 for i in range(10): for j in range(10): if area[i][j] == 0: cnt += 1 if area[i][j] > max: max = area[i][j] print(cnt) print(max)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s683667246
p00026
Wrong Answer
import sys lines = [] for line in sys.stdin: lines.append(line.strip().split(',')) field = [[0 for i in range(10)] for j in range(10)]
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s784331640
p00026
Wrong Answer
import sys lines = [] for line in sys.stdin: lines.append(line.strip().split(',')) field = [[0 for i in range(10)] for j in range(10)] def drop(x, y, z): if z==1: for i in range(-1,2): for j in range(-1,2): if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 elif z==2: for i in range(-1,2): for j in range(-1,2): if 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 else: for i in range(-2,3): for j in range(-2,3): if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s131154299
p00026
Wrong Answer
import sys lines = [] for line in sys.stdin: lines.append(line.strip().split(',')) field = [[0 for i in range(10)] for j in range(10)] def drop(x, y, z): if z==1: for i in range(-1,2): for j in range(-1,2): if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 elif z==2: for i in range(-1,2): for j in range(-1,2): if 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 else: for i in range(-2,3): for j in range(-2,3): if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 drop(1,1,1)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s238208352
p00026
Wrong Answer
import sys lines = [] for line in sys.stdin: lines.append(line.strip().split(',')) field = [[0 for i in range(10)] for j in range(10)] def drop(x, y, z): if z==1: for i in range(-1,2): for j in range(-1,2): if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 elif z==2: for i in range(-1,2): for j in range(-1,2): if 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 else: for i in range(-2,3): for j in range(-2,3): if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 for line in lines: x,y,z = map(int, line) drop(1,1,1)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s089739881
p00026
Wrong Answer
import sys lines = [] for line in sys.stdin: lines.append(line.strip().split(',')) field = [[0 for i in range(10)] for j in range(10)] def drop(x, y, z): if z==1: for i in range(-1,2): for j in range(-1,2): if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 elif z==2: for i in range(-1,2): for j in range(-1,2): if 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 else: for i in range(-2,3): for j in range(-2,3): if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 for line in lines: x,y,z = map(int, line) #drop(x,y,z) n = 0 m = 0 for f in field: for e in f: if e > m: m = e if e==0: n+=1 print(n) print(m)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s312714823
p00026
Wrong Answer
import sys lines = [] for line in sys.stdin: lines.append(line.strip().split(',')) field = [[0 for i in range(10)] for j in range(10)] def drop(x, y, z): if z==1: for i in range(-1,2): for j in range(-1,2): if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 elif z==2: for i in range(-1,2): for j in range(-1,2): if 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 else: for i in range(-2,3): for j in range(-2,3): if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10: field[y+j][x+i] += 1 for line in lines: x,y,z = map(int, line) drop(1,1,1) n = 0 m = 0 for f in field: for e in f: if e > m: m = e if e==0: n+=1 print(n) print(m)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s629522698
p00026
Wrong Answer
#sheet...紙全体、sheet[x][y]は(x, y)のインクの濃さ sheet = [[0 for _ in range(10)] for _ in range(10)] #小、中、大のインクの範囲 small_range = ((0, 0), (1, 0), (0, 1), (-1, 0), (0, 1)) middle_range = ((0, 0), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)) large_range = ((0, 0), (1, 0), (2, 0), (1, 1), (0, 1), (0, 2), (-1, 1), (-1, 0), (-2, 0), (-1, -1), (0, -1), (0, -2), (1, -1)) #範囲内か判定してインクを足す def drop(x, y, drop_range): for dx, dy in drop_range: newx, newy = x + dx, y + dy if 0 <= newx <= 9 and 0 <= newy <= 9: sheet[newx][newy] += 1 while True: try: x, y, s = map(int, input().split(",")) if s == 1: drop(x, y, small_range) elif s == 2: drop(x, y, middle_range) else: drop(x, y, large_range) except EOFError: break #0の個数 zero_cnt = 0 #インクの最大値 max_ink = 0 for x in range(10): for y in range(10): ink = sheet[x][y] if ink == 0: zero_cnt += 1 if max_ink < ink: max_ink = ink print(zero_cnt) print(max_ink)
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s289738111
p00026
Wrong Answer
class Cloth(object): cell = None def __init__(self, x, y): self.cell = list([list([0 for i in range(y)]) for i in range(x)]) def point(self, x, y): try: self.cell[x][y] += 1 except IndexError: pass def small(self, x, y): self.point(x, y + 1) self.point(x - 1, y) self.point(x, y) self.point(x + 1, y) self.point(x, y - 1) def medium(self, x, y): self.small(x, y) self.point(x + 1, y + 1) self.point(x - 1, y + 1) self.point(x + 1, y - 1) self.point(x - 1, y - 1) def large(self, x, y): self.medium(x, y) self.point(x, y + 2) self.point(x - 2, y) self.point(x + 2, y) self.point(x, y - 2) cloth = Cloth(10, 10) while True: try: (x, y, s) = map(int, raw_input().split(',')) if s == 1: cloth.small(x, y) elif s == 2: cloth.medium(x, y) elif s == 3: cloth.large(x, y) except EOFError: break print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell)) print max(map(max,cloth.cell))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s937587841
p00026
Wrong Answer
class Cloth(object): cell = None x = 0 y = 0 def __init__(self, x, y): self.cell = list([list([0 for i in range(y)]) for i in range(x)]) self.x = x self.y = y def check(self, x, y): try: self.cell[x][y] += 0 return True except IndexError: return False def point(self, x, y): try: self.cell[x][y] += 1 except IndexError: pass def small(self, x, y): if not self.check(x, y): return self.point(x, y + 1) self.point(x - 1, y) self.point(x, y) self.point(x + 1, y) self.point(x, y - 1) def medium(self, x, y): if not self.check(x, y): return self.small(x, y) self.point(x + 1, y + 1) self.point(x - 1, y + 1) self.point(x + 1, y - 1) self.point(x - 1, y - 1) def large(self, x, y): if not self.check(x, y): return self.medium(x, y) self.point(x, y + 2) self.point(x - 2, y) self.point(x + 2, y) self.point(x, y - 2) cloth = Cloth(10, 10) while True: print cloth.cell try: (x, y, s) = map(int, raw_input().split(',')) if s == 1: cloth.small(x, y) elif s == 2: cloth.medium(x, y) elif s == 3: cloth.large(x, y) else: break except EOFError: break print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell)) print max(map(max,cloth.cell))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s918883567
p00026
Wrong Answer
class Cloth(object): cell = None x = 0 y = 0 def __init__(self, x, y): self.cell = list([list([0 for i in range(y)]) for i in range(x)]) self.x = x self.y = y def check(self, x, y): try: self.cell[x][y] += 0 return True except IndexError: return False def point(self, x, y): try: self.cell[x][y] += 1 except IndexError: pass def small(self, x, y): if not self.check(x, y): return self.point(x, y + 1) self.point(x - 1, y) self.point(x, y) self.point(x + 1, y) self.point(x, y - 1) def medium(self, x, y): if not self.check(x, y): return self.small(x, y) self.point(x + 1, y + 1) self.point(x - 1, y + 1) self.point(x + 1, y - 1) self.point(x - 1, y - 1) def large(self, x, y): if not self.check(x, y): return self.medium(x, y) self.point(x, y + 2) self.point(x - 2, y) self.point(x + 2, y) self.point(x, y - 2) cloth = Cloth(10, 10) while True: print cloth.cell try: (x, y, s) = map(lambda x:int(x)-1, raw_input().split(',')) if s == 0: cloth.small(x, y) elif s == 1: cloth.medium(x, y) elif s == 2: cloth.large(x, y) else: break except EOFError: break print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell)) print max(map(max,cloth.cell))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s540109991
p00026
Wrong Answer
class Cloth(object): cell = None x = 0 y = 0 def __init__(self, x, y): self.cell = list([list([0 for i in range(y)]) for i in range(x)]) self.x = x self.y = y def check(self, x, y): try: self.cell[x][y] += 0 return True except IndexError: return False def point(self, x, y): try: self.cell[x][y] += 1 except IndexError: pass def small(self, x, y): if not self.check(x, y): return self.point(x, y + 1) self.point(x - 1, y) self.point(x, y) self.point(x + 1, y) self.point(x, y - 1) def medium(self, x, y): if not self.check(x, y): return self.small(x, y) self.point(x + 1, y + 1) self.point(x - 1, y + 1) self.point(x + 1, y - 1) self.point(x - 1, y - 1) def large(self, x, y): if not self.check(x, y): return self.medium(x, y) self.point(x, y + 2) self.point(x - 2, y) self.point(x + 2, y) self.point(x, y - 2) cloth = Cloth(10, 10) while True: try: (x, y, s) = map(lambda x:int(x)-1, raw_input().split(',')) if s == 0: cloth.small(x, y) elif s == 1: cloth.medium(x, y) elif s == 2: cloth.large(x, y) else: break except EOFError: break print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell)) print max(map(max,cloth.cell))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s003992105
p00026
Wrong Answer
class Cloth(object): cell = None x = 0 y = 0 def __init__(self, x, y): self.cell = list([list([0 for i in range(y)]) for i in range(x)]) self.x = x self.y = y def check(self, x, y): try: self.cell[x][y] += 0 return True except IndexError: return False def point(self, x, y): try: self.cell[x][y] += 1 except IndexError: pass def small(self, x, y): if not self.check(x, y): return self.point(x, y + 1) self.point(x - 1, y) self.point(x, y) self.point(x + 1, y) self.point(x, y - 1) def medium(self, x, y): if not self.check(x, y): return self.small(x, y) self.point(x + 1, y + 1) self.point(x - 1, y + 1) self.point(x + 1, y - 1) self.point(x - 1, y - 1) def large(self, x, y): if not self.check(x, y): return self.medium(x, y) self.point(x, y + 2) self.point(x - 2, y) self.point(x + 2, y) self.point(x, y - 2) cloth = Cloth(10, 10) while True: try: (x, y, s) = map(lambda x:int(x)-1, raw_input().split(',')) if s == 0: cloth.small(x, y) elif s == 1: cloth.medium(x, y) elif s == 2: cloth.large(x, y) except EOFError: break print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cloth.cell)) print max(map(max,cloth.cell))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>
s361799773
p00026
Wrong Answer
cell = [[0] * 10 for i in xrange(10)] large = [[0,0,1,0,0], [0,1,1,1,0], [1,1,1,1,1], [0,1,1,1,0], [0,0,1,0,0]] medium= [[0,0,0,0,0], [0,1,1,1,0], [0,1,1,1,0], [0,1,1,1,0], [0,0,0,0,0]] small = [[0,0,0,0,0], [0,0,1,0,0], [0,1,1,1,0], [0,0,1,0,0], [0,0,0,0,0]] size = [0,small,medium,large] while True: try: x, y, s = [int(i) for i in raw_input().split(',')] except EOFError: break except ValueError: break p = size[s] for i in xrange(5): for j in xrange(5): try: cell[i+x-2][j+y-2] += p[i][j] except IndexError: pass print reduce(lambda x,y:x+y,map(lambda x:x.count(0),cell)) print max(map(max,cell))
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink1"></center> <br/> <p> Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ink2"></center> <br/> <p> In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. </p> <p> Your task is to write a program which reads a sequence of points of fall (<var>x</var>, <var>y</var>) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. </p> <p> You may assume that the paper always consists of 10 &times; 10, and 0 &le; <var>x</var> &lt; 10, 0 &le; <var>y</var> &lt; 10. </p> <H2>Input</H2> <pre> <var>x<sub>1</sub></var>,<var>y<sub>1</sub></var>,<var>s<sub>1</sub></var> <var>x<sub>2</sub></var>,<var>y<sub>2</sub></var>,<var>s<sub>2</sub></var> : : </pre> <p> (<var>x<sub>i</sub></var>, <var>y<sub>i</sub></var>) represents the position of the <var>i</var>-th drop and <var>s<sub>i</sub></var> denotes its size. The number of drops is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of cells whose density value is 0 in first line.<br> Print the maximum value of density in the second line. </p> <H2>Sample Input</H2> <pre> 2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1 </pre> <H2>Output for the Sample Input</H2> <pre> 77 5 </pre>