message stringlengths 2 44.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 276 109k | cluster float64 23 23 | __index_level_0__ int64 552 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's denote a m-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submatrix of size m × m of this matrix contains at least one zero.
Consider the following problem:
You are given two integers n and m. You have to construct an m-free square matrix of size n × n such that the number of 1's in this matrix is maximum possible. Print the maximum possible number of 1's in such matrix.
You don't have to solve this problem. Instead, you have to construct a few tests for it.
You will be given t numbers x1, x2, ..., xt. For every <image>, find two integers ni and mi (ni ≥ mi) such that the answer for the aforementioned problem is exactly xi if we set n = ni and m = mi.
Input
The first line contains one integer t (1 ≤ t ≤ 100) — the number of tests you have to construct.
Then t lines follow, i-th line containing one integer xi (0 ≤ xi ≤ 109).
Note that in hacks you have to set t = 1.
Output
For each test you have to construct, output two positive numbers ni and mi (1 ≤ mi ≤ ni ≤ 109) such that the maximum number of 1's in a mi-free ni × ni matrix is exactly xi. If there are multiple solutions, you may output any of them; and if this is impossible to construct a test, output a single integer - 1.
Example
Input
3
21
0
1
Output
5 2
1 1
-1
Submitted Solution:
```
import math
n = int(input())
a = [int(input()) for i in range(n)]
for el in a:
k = 0
f = True
while f and k <= el + 100:
k += 1
i = k * k
x = (el + i) ** 0.5
if x - math.floor(x) < 0.0001:
print(int(x), k)
f = False
if f == True:
print(-1)
``` | instruction | 0 | 19,106 | 23 | 38,212 |
No | output | 1 | 19,106 | 23 | 38,213 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rectangle with sides A and B is cut into rectangles with cuts parallel to its sides. For example, if p horizontal and q vertical cuts were made, (p + 1) ⋅ (q + 1) rectangles were left after the cutting. After the cutting, rectangles were of n different types. Two rectangles are different if at least one side of one rectangle isn't equal to the corresponding side of the other. Note that the rectangle can't be rotated, this means that rectangles a × b and b × a are considered different if a ≠ b.
For each type of rectangles, lengths of the sides of rectangles are given along with the amount of the rectangles of this type that were left after cutting the initial rectangle.
Calculate the amount of pairs (A; B) such as the given rectangles could be created by cutting the rectangle with sides of lengths A and B. Note that pairs (A; B) and (B; A) are considered different when A ≠ B.
Input
The first line consists of a single integer n (1 ≤ n ≤ 2 ⋅ 10^{5}) — amount of different types of rectangles left after cutting the initial rectangle.
The next n lines each consist of three integers w_{i}, h_{i}, c_{i} (1 ≤ w_{i}, h_{i}, c_{i} ≤ 10^{12}) — the lengths of the sides of the rectangles of this type and the amount of the rectangles of this type.
It is guaranteed that the rectangles of the different types are different.
Output
Output one integer — the answer to the problem.
Examples
Input
1
1 1 9
Output
3
Input
2
2 3 20
2 4 40
Output
6
Input
2
1 2 5
2 3 5
Output
0
Note
In the first sample there are three suitable pairs: (1; 9), (3; 3) and (9; 1).
In the second sample case there are 6 suitable pairs: (2; 220), (4; 110), (8; 55), (10; 44), (20; 22) and (40; 11).
Here the sample of cut for (20; 22).
<image>
The third sample has no suitable pairs. | instruction | 0 | 19,107 | 23 | 38,214 |
Tags: brute force, math, number theory
Correct Solution:
```
n =int(input())
w=[]
h=[]
c=[]
cntw={}
cnth={}
multMayotC=0
cntC=0
def insert1(a,b,c):
if not a in b :
b[a]=c
else :
b[a]=b[a]+c
def multMayot(a,b):
if a % b == 0 :
return b
else :
return multMayot(b,a%b)
for i in range(0, n):
a,b,d = map(int,input().split())
w.append(a)
h.append(b)
c.append(d)
insert1(a,cntw,d)
insert1(b,cnth,d)
cntC += d
if multMayotC == 0 :
multMayotC = d
else:
multMayotC = multMayot(multMayotC, d)
for i in range(0, n):
if cntw[w[i]] * cnth[h[i]] != cntC * c[i]:
print (0)
exit()
result = 0
i = 1
while (i * i <= multMayotC) :
if multMayotC % i == 0 :
result += 1
if i * i != multMayotC :
result += 1
i += 1
print (result)
``` | output | 1 | 19,107 | 23 | 38,215 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rectangle with sides A and B is cut into rectangles with cuts parallel to its sides. For example, if p horizontal and q vertical cuts were made, (p + 1) ⋅ (q + 1) rectangles were left after the cutting. After the cutting, rectangles were of n different types. Two rectangles are different if at least one side of one rectangle isn't equal to the corresponding side of the other. Note that the rectangle can't be rotated, this means that rectangles a × b and b × a are considered different if a ≠ b.
For each type of rectangles, lengths of the sides of rectangles are given along with the amount of the rectangles of this type that were left after cutting the initial rectangle.
Calculate the amount of pairs (A; B) such as the given rectangles could be created by cutting the rectangle with sides of lengths A and B. Note that pairs (A; B) and (B; A) are considered different when A ≠ B.
Input
The first line consists of a single integer n (1 ≤ n ≤ 2 ⋅ 10^{5}) — amount of different types of rectangles left after cutting the initial rectangle.
The next n lines each consist of three integers w_{i}, h_{i}, c_{i} (1 ≤ w_{i}, h_{i}, c_{i} ≤ 10^{12}) — the lengths of the sides of the rectangles of this type and the amount of the rectangles of this type.
It is guaranteed that the rectangles of the different types are different.
Output
Output one integer — the answer to the problem.
Examples
Input
1
1 1 9
Output
3
Input
2
2 3 20
2 4 40
Output
6
Input
2
1 2 5
2 3 5
Output
0
Note
In the first sample there are three suitable pairs: (1; 9), (3; 3) and (9; 1).
In the second sample case there are 6 suitable pairs: (2; 220), (4; 110), (8; 55), (10; 44), (20; 22) and (40; 11).
Here the sample of cut for (20; 22).
<image>
The third sample has no suitable pairs. | instruction | 0 | 19,108 | 23 | 38,216 |
Tags: brute force, math, number theory
Correct Solution:
```
n =int(input())
w=[]
h=[]
c=[]
cntw={}
cnth={}
gcdC=0
cntC=0
def insert1(a,b,c):
if not a in b :
b[a]=c
else :
b[a]=b[a]+c
def gcd(a,b):
if a % b == 0 :
return b
else :
return gcd(b,a%b)
for i in range(0, n):
a,b,d = map(int,input().split())
w.append(a)
h.append(b)
c.append(d)
insert1(a,cntw,d)
insert1(b,cnth,d)
cntC += d
if gcdC == 0 :
gcdC = d
else :
gcdC = gcd(gcdC, d)
for i in range(0, n):
if cntw[w[i]] * cnth[h[i]] != cntC * c[i]:
print (0)
exit()
ans = 0
i = 1
while (i * i <= gcdC) :
if gcdC % i == 0 :
ans += 1
if i * i != gcdC :
ans += 1
i += 1
print (ans)
``` | output | 1 | 19,108 | 23 | 38,217 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rectangle with sides A and B is cut into rectangles with cuts parallel to its sides. For example, if p horizontal and q vertical cuts were made, (p + 1) ⋅ (q + 1) rectangles were left after the cutting. After the cutting, rectangles were of n different types. Two rectangles are different if at least one side of one rectangle isn't equal to the corresponding side of the other. Note that the rectangle can't be rotated, this means that rectangles a × b and b × a are considered different if a ≠ b.
For each type of rectangles, lengths of the sides of rectangles are given along with the amount of the rectangles of this type that were left after cutting the initial rectangle.
Calculate the amount of pairs (A; B) such as the given rectangles could be created by cutting the rectangle with sides of lengths A and B. Note that pairs (A; B) and (B; A) are considered different when A ≠ B.
Input
The first line consists of a single integer n (1 ≤ n ≤ 2 ⋅ 10^{5}) — amount of different types of rectangles left after cutting the initial rectangle.
The next n lines each consist of three integers w_{i}, h_{i}, c_{i} (1 ≤ w_{i}, h_{i}, c_{i} ≤ 10^{12}) — the lengths of the sides of the rectangles of this type and the amount of the rectangles of this type.
It is guaranteed that the rectangles of the different types are different.
Output
Output one integer — the answer to the problem.
Examples
Input
1
1 1 9
Output
3
Input
2
2 3 20
2 4 40
Output
6
Input
2
1 2 5
2 3 5
Output
0
Note
In the first sample there are three suitable pairs: (1; 9), (3; 3) and (9; 1).
In the second sample case there are 6 suitable pairs: (2; 220), (4; 110), (8; 55), (10; 44), (20; 22) and (40; 11).
Here the sample of cut for (20; 22).
<image>
The third sample has no suitable pairs.
Submitted Solution:
```
import math
q = int(input())
l, A, B = 0, 0, 0
for i in range(q):
v = input().split()
l += int(v[2])
A += int(v[0]) * int(v[2])
B += int(v[1]) * int(v[2])
# print('l %s' % l)
# print('A %s' % A)
# print('B %s' % B)
r = 0
d = []
for i in range(1 , int(math.sqrt(l)) + 1):
if l % i == 0:
n = i
m = int(l / i)
if A % n == 0 and B % m == 0:
r += 1
if n != m:
n, m = m, n
if A % n == 0 and B % m == 0:
r += 1
print(r)
``` | instruction | 0 | 19,109 | 23 | 38,218 |
No | output | 1 | 19,109 | 23 | 38,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rectangle with sides A and B is cut into rectangles with cuts parallel to its sides. For example, if p horizontal and q vertical cuts were made, (p + 1) ⋅ (q + 1) rectangles were left after the cutting. After the cutting, rectangles were of n different types. Two rectangles are different if at least one side of one rectangle isn't equal to the corresponding side of the other. Note that the rectangle can't be rotated, this means that rectangles a × b and b × a are considered different if a ≠ b.
For each type of rectangles, lengths of the sides of rectangles are given along with the amount of the rectangles of this type that were left after cutting the initial rectangle.
Calculate the amount of pairs (A; B) such as the given rectangles could be created by cutting the rectangle with sides of lengths A and B. Note that pairs (A; B) and (B; A) are considered different when A ≠ B.
Input
The first line consists of a single integer n (1 ≤ n ≤ 2 ⋅ 10^{5}) — amount of different types of rectangles left after cutting the initial rectangle.
The next n lines each consist of three integers w_{i}, h_{i}, c_{i} (1 ≤ w_{i}, h_{i}, c_{i} ≤ 10^{12}) — the lengths of the sides of the rectangles of this type and the amount of the rectangles of this type.
It is guaranteed that the rectangles of the different types are different.
Output
Output one integer — the answer to the problem.
Examples
Input
1
1 1 9
Output
3
Input
2
2 3 20
2 4 40
Output
6
Input
2
1 2 5
2 3 5
Output
0
Note
In the first sample there are three suitable pairs: (1; 9), (3; 3) and (9; 1).
In the second sample case there are 6 suitable pairs: (2; 220), (4; 110), (8; 55), (10; 44), (20; 22) and (40; 11).
Here the sample of cut for (20; 22).
<image>
The third sample has no suitable pairs.
Submitted Solution:
```
import math
q = int(input())
l, A, B = 0, 0, 0
for i in range(q):
v = input().split()
l += int(v[2])
A += int(v[0]) * int(v[2])
B += int(v[1]) * int(v[2])
r = 0
d = []
for i in range(1 , int(math.sqrt(l)) + 1):
if l % i == 0:
n = i
m = int(l / i)
if A % n == 0 and B % m == 0:
r += 1
n, m = m, n
if A % n == 0 and B % m == 0:
r += 1
print(r)
``` | instruction | 0 | 19,110 | 23 | 38,220 |
No | output | 1 | 19,110 | 23 | 38,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rectangle with sides A and B is cut into rectangles with cuts parallel to its sides. For example, if p horizontal and q vertical cuts were made, (p + 1) ⋅ (q + 1) rectangles were left after the cutting. After the cutting, rectangles were of n different types. Two rectangles are different if at least one side of one rectangle isn't equal to the corresponding side of the other. Note that the rectangle can't be rotated, this means that rectangles a × b and b × a are considered different if a ≠ b.
For each type of rectangles, lengths of the sides of rectangles are given along with the amount of the rectangles of this type that were left after cutting the initial rectangle.
Calculate the amount of pairs (A; B) such as the given rectangles could be created by cutting the rectangle with sides of lengths A and B. Note that pairs (A; B) and (B; A) are considered different when A ≠ B.
Input
The first line consists of a single integer n (1 ≤ n ≤ 2 ⋅ 10^{5}) — amount of different types of rectangles left after cutting the initial rectangle.
The next n lines each consist of three integers w_{i}, h_{i}, c_{i} (1 ≤ w_{i}, h_{i}, c_{i} ≤ 10^{12}) — the lengths of the sides of the rectangles of this type and the amount of the rectangles of this type.
It is guaranteed that the rectangles of the different types are different.
Output
Output one integer — the answer to the problem.
Examples
Input
1
1 1 9
Output
3
Input
2
2 3 20
2 4 40
Output
6
Input
2
1 2 5
2 3 5
Output
0
Note
In the first sample there are three suitable pairs: (1; 9), (3; 3) and (9; 1).
In the second sample case there are 6 suitable pairs: (2; 220), (4; 110), (8; 55), (10; 44), (20; 22) and (40; 11).
Here the sample of cut for (20; 22).
<image>
The third sample has no suitable pairs.
Submitted Solution:
```
import math
q = int(input())
l, A, B = 0, 0, 0
for i in range(q):
v = input().split()
l += int(v[2])
A += int(v[0]) * int(v[2])
B += int(v[1]) * int(v[2])
d = []
for i in range(1 , int(math.sqrt(l)) + 1):
if l % i == 0:
a = (i, int(l / i))
if a not in d:
d.append(a)
a = (int(l / i), i)
if a not in d:
d.append(a)
r = 0
for n, m in d:
if A % n == 0 and B % m == 0:
r += 1
print(r)
``` | instruction | 0 | 19,111 | 23 | 38,222 |
No | output | 1 | 19,111 | 23 | 38,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rectangle with sides A and B is cut into rectangles with cuts parallel to its sides. For example, if p horizontal and q vertical cuts were made, (p + 1) ⋅ (q + 1) rectangles were left after the cutting. After the cutting, rectangles were of n different types. Two rectangles are different if at least one side of one rectangle isn't equal to the corresponding side of the other. Note that the rectangle can't be rotated, this means that rectangles a × b and b × a are considered different if a ≠ b.
For each type of rectangles, lengths of the sides of rectangles are given along with the amount of the rectangles of this type that were left after cutting the initial rectangle.
Calculate the amount of pairs (A; B) such as the given rectangles could be created by cutting the rectangle with sides of lengths A and B. Note that pairs (A; B) and (B; A) are considered different when A ≠ B.
Input
The first line consists of a single integer n (1 ≤ n ≤ 2 ⋅ 10^{5}) — amount of different types of rectangles left after cutting the initial rectangle.
The next n lines each consist of three integers w_{i}, h_{i}, c_{i} (1 ≤ w_{i}, h_{i}, c_{i} ≤ 10^{12}) — the lengths of the sides of the rectangles of this type and the amount of the rectangles of this type.
It is guaranteed that the rectangles of the different types are different.
Output
Output one integer — the answer to the problem.
Examples
Input
1
1 1 9
Output
3
Input
2
2 3 20
2 4 40
Output
6
Input
2
1 2 5
2 3 5
Output
0
Note
In the first sample there are three suitable pairs: (1; 9), (3; 3) and (9; 1).
In the second sample case there are 6 suitable pairs: (2; 220), (4; 110), (8; 55), (10; 44), (20; 22) and (40; 11).
Here the sample of cut for (20; 22).
<image>
The third sample has no suitable pairs.
Submitted Solution:
```
import math
q = int(input())
l, A, B = 0, 0, 0
for i in range(q):
v = input().split()
l += int(v[2])
A += int(v[0]) * int(v[2])
B += int(v[1]) * int(v[2])
print('l %s' % l)
print('A %s' % A)
print('B %s' % B)
r = 0
d = []
for i in range(1 , int(math.sqrt(l)) + 1):
if l % i == 0:
n = i
m = int(l / i)
if A % n == 0 and B % m == 0:
r += 1
if n != m:
n, m = m, n
if A % n == 0 and B % m == 0:
r += 1
print(r)
``` | instruction | 0 | 19,112 | 23 | 38,224 |
No | output | 1 | 19,112 | 23 | 38,225 |
Provide a correct Python 3 solution for this coding contest problem.
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.
The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.
How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
Constraints
* 1 \leq H, W \leq N \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
H
W
Output
Print the answer.
Examples
Input
3
2
3
Output
2
Input
100
1
1
Output
10000
Input
5
4
2
Output
8 | instruction | 0 | 19,186 | 23 | 38,372 |
"Correct Solution:
```
N, H, W = int(input()), int(input()), int(input())
print((N - H + 1) * (N - W + 1))
``` | output | 1 | 19,186 | 23 | 38,373 |
Provide a correct Python 3 solution for this coding contest problem.
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.
The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.
How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
Constraints
* 1 \leq H, W \leq N \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
H
W
Output
Print the answer.
Examples
Input
3
2
3
Output
2
Input
100
1
1
Output
10000
Input
5
4
2
Output
8 | instruction | 0 | 19,187 | 23 | 38,374 |
"Correct Solution:
```
n = int(input())
h = int(input())
w = int(input())
ans = (n-h+1)*(n-w+1)
print(ans)
``` | output | 1 | 19,187 | 23 | 38,375 |
Provide a correct Python 3 solution for this coding contest problem.
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.
The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.
How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
Constraints
* 1 \leq H, W \leq N \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
H
W
Output
Print the answer.
Examples
Input
3
2
3
Output
2
Input
100
1
1
Output
10000
Input
5
4
2
Output
8 | instruction | 0 | 19,188 | 23 | 38,376 |
"Correct Solution:
```
N=int(input())
H=int(input())
W=int(input())
print((N-W+1)*(N-H+1))
``` | output | 1 | 19,188 | 23 | 38,377 |
Provide a correct Python 3 solution for this coding contest problem.
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.
The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.
How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
Constraints
* 1 \leq H, W \leq N \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
H
W
Output
Print the answer.
Examples
Input
3
2
3
Output
2
Input
100
1
1
Output
10000
Input
5
4
2
Output
8 | instruction | 0 | 19,189 | 23 | 38,378 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
n = int(input())
h = int(input())
w = int(input())
x=int(0)
x=(n-h+1)*(n-w+1)
print(x)
``` | output | 1 | 19,189 | 23 | 38,379 |
Provide a correct Python 3 solution for this coding contest problem.
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.
The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.
How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
Constraints
* 1 \leq H, W \leq N \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
H
W
Output
Print the answer.
Examples
Input
3
2
3
Output
2
Input
100
1
1
Output
10000
Input
5
4
2
Output
8 | instruction | 0 | 19,190 | 23 | 38,380 |
"Correct Solution:
```
# x,y=map(int,input().split())
n=int(input())
h=int(input())
w=int(input())
print((n-w+1)*(n-h+1))
``` | output | 1 | 19,190 | 23 | 38,381 |
Provide a correct Python 3 solution for this coding contest problem.
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.
The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.
How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
Constraints
* 1 \leq H, W \leq N \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
H
W
Output
Print the answer.
Examples
Input
3
2
3
Output
2
Input
100
1
1
Output
10000
Input
5
4
2
Output
8 | instruction | 0 | 19,191 | 23 | 38,382 |
"Correct Solution:
```
n = int(input())
h = int(input())
w = int(input())
print(max(0,n-w+1)*max(0,n-h+1))
``` | output | 1 | 19,191 | 23 | 38,383 |
Provide a correct Python 3 solution for this coding contest problem.
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.
The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.
How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
Constraints
* 1 \leq H, W \leq N \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
H
W
Output
Print the answer.
Examples
Input
3
2
3
Output
2
Input
100
1
1
Output
10000
Input
5
4
2
Output
8 | instruction | 0 | 19,192 | 23 | 38,384 |
"Correct Solution:
```
N = int(input())
H = int(input())
W = int(input())
tate = (N-H)+1
yoko = (N-W)+1
print(tate*yoko)
``` | output | 1 | 19,192 | 23 | 38,385 |
Provide a correct Python 3 solution for this coding contest problem.
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.
The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.
How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
Constraints
* 1 \leq H, W \leq N \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
H
W
Output
Print the answer.
Examples
Input
3
2
3
Output
2
Input
100
1
1
Output
10000
Input
5
4
2
Output
8 | instruction | 0 | 19,193 | 23 | 38,386 |
"Correct Solution:
```
n=int(input())
w=int(input())
h=int(input())
print((n - w + 1)*(n - h + 1))
``` | output | 1 | 19,193 | 23 | 38,387 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64 | instruction | 0 | 19,266 | 23 | 38,532 |
"Correct Solution:
```
W,H,N=map(int,input().split())
a,b,c,d=0,W,0,H
for i in range(N):
x,y,A=map(int,input().split())
if A==1:
a=max(a,x)
if A==2:
b=min(b,x)
if A==3:
c=max(c,y)
if A==4:
d=min(d,y)
print(max(0,b-a)*max(0,d-c))
``` | output | 1 | 19,266 | 23 | 38,533 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64 | instruction | 0 | 19,267 | 23 | 38,534 |
"Correct Solution:
```
# coding: utf-8
w,h,N=list(map(int,input().split()))
rect=[0,w,0,h]
for i in range(N):
x,y,a=list(map(int, input().split()))
rect[a-1]=(lambda c,r,p:[r,c][p*(c-r)<0])([x,y][a>2],rect[a-1],[1,-1][a%2])
length=lambda x:[x,0][x<0]
print(length(rect[1]-rect[0])*length(rect[3]-rect[2]))
``` | output | 1 | 19,267 | 23 | 38,535 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64 | instruction | 0 | 19,268 | 23 | 38,536 |
"Correct Solution:
```
w,h,n=map(int,input().split())
p,q,r,s=0,w,0,h
for i in range(n):
x,y,a=map(int,input().split())
if a==1:
p=max(p,x)
elif a==2:
q=min(q,x)
elif a==3:
r=max(r,y)
elif a==4:
s=min(s,y)
print(max(0,q-p)*max(0,s-r))
``` | output | 1 | 19,268 | 23 | 38,537 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64 | instruction | 0 | 19,269 | 23 | 38,538 |
"Correct Solution:
```
w, h, n = map(int, input().split())
b = 0
c = 0
for _ in range(n):
x, y, a = map(int, input().split())
if a == 1:
b = max(b, x)
elif a == 2:
w = min(w, x)
elif a == 3:
c = max(c, y)
elif a == 4:
h = min(h, y)
print(max(0, (w-b)) * max(0, (h-c)))
``` | output | 1 | 19,269 | 23 | 38,539 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64 | instruction | 0 | 19,270 | 23 | 38,540 |
"Correct Solution:
```
w,h,n=map(int,input().split())
b=c=0
for _ in [0]*n:
x,y,a=map(int,input().split())
if a==1:b=max(b,x)
if a==2:w=min(w,x)
if a==3:c=max(c,y)
if a==4:h=min(h,y)
print([(w-b)*(h-c),0][(w<b)|(h<c)])
``` | output | 1 | 19,270 | 23 | 38,541 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64 | instruction | 0 | 19,271 | 23 | 38,542 |
"Correct Solution:
```
W,H,N=map(int,input().split())
W0,H0=0,0
for i in range(N):
x,y,a=map(int,input().split())
if a==1:
W0=max(x,W0)
elif a==2:
W=min(x,W)
elif a==3:
H0=max(y,H0)
else:
H=min(y,H)
if W-W0<0 or H-H0<0:
print(0)
else:
print((W-W0)*(H-H0))
``` | output | 1 | 19,271 | 23 | 38,543 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64 | instruction | 0 | 19,272 | 23 | 38,544 |
"Correct Solution:
```
w,h,n = map(int,input().split())
x0,y0 = 0,0
for i in range(n):
x,y,a = map(int,input().split())
if a==1:
x0=max(x0,x)
elif a==2:
w=min(w,x)
elif a==3:
y0=max(y0,y)
else:
h=min(h,y)
print(0 if w-x0<=0 or h-y0<=0 else (w-x0)*(h-y0))
``` | output | 1 | 19,272 | 23 | 38,545 |
Provide a correct Python 3 solution for this coding contest problem.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64 | instruction | 0 | 19,273 | 23 | 38,546 |
"Correct Solution:
```
w, h , n = map(int, input().split())
x1=0
y1=0
x2=w
y2=h
for i in range(0,n):
x , y, a = map(int , input().split())
if a==1:
x1 = max(x1,x)
elif a==2:
x2=min(x2, x)
elif a==3:
y1=max(y1, y)
else:
y2=min(y2, y)
ar=(y2-y1)*(x2-x1)
if y2-y1<=0 or x2-x1<=0:
print(0)
else:
print(ar)
``` | output | 1 | 19,273 | 23 | 38,547 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64
Submitted Solution:
```
W,H,N = map(int,input().split())
XYA = [tuple(map(int,input().split())) for i in range(N)]
l,r,d,u = 0,W,0,H
for x,y,a in XYA:
if a==1:
l = max(l,x)
elif a==2:
r = min(r,x)
elif a==3:
d = max(d,y)
else:
u = min(u,y)
w = max(0,r-l)
h = max(0,u-d)
print(w*h)
``` | instruction | 0 | 19,274 | 23 | 38,548 |
Yes | output | 1 | 19,274 | 23 | 38,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64
Submitted Solution:
```
w,h,n=map(int,input().split())
x_min=0
y_min=0
for i in range(n):
x,y,a=map(int,input().split())
if a==1:
x_min=max(x_min,x)
elif a==2:
w=min(x,w)
elif a==3:
y_min=max(y_min,y)
elif a==4:
h=min(y,h)
print(max(0,w-x_min)*max(0,h-y_min))
``` | instruction | 0 | 19,275 | 23 | 38,550 |
Yes | output | 1 | 19,275 | 23 | 38,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64
Submitted Solution:
```
W,H,N=map(int,input().split())
x0,y0=0,0
for i in range(N):
x,y,a=map(int,input().split())
if a==1 and x>x0:
x0=x
elif a==2 and x<W:
W=x
elif a==3 and y>y0:
y0=y
elif a==4 and y<H:
H=y
if W<x0 or H<y0:
print(0)
else:
print((W-x0)*(H-y0))
``` | instruction | 0 | 19,276 | 23 | 38,552 |
Yes | output | 1 | 19,276 | 23 | 38,553 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64
Submitted Solution:
```
W, H, N = map(int,input().split())
l = 0
r = W
u = H
d = 0
for i in range(N):
x, y, a = map(int,input().split())
if a == 1:
l = max(x,l)
elif a == 2:
r = min(x,r)
elif a == 3:
d = max(y,d)
else:
u = min(y,u)
print(max((r-l),0)*max((u-d),0))
``` | instruction | 0 | 19,277 | 23 | 38,554 |
Yes | output | 1 | 19,277 | 23 | 38,555 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64
Submitted Solution:
```
w, h, n = [int(i) for i in input().split()]
w2, h2 = w, h
wb, hb = [False] * w, [False] * h
for i in range(n):
x, y, a = [int(i) for i in input().split()]
if a == 1 and not wb[x]:
w2 -= x
wb[x] = True
elif a == 2 and not wb[x]:
w2 -= w - x
wb[x] = True
elif a == 3 and not hb[y]:
h2 -= y
hb[y] = True
elif a == 4 and not hb[y]:
h2 -= h - y
hb[y] = True
ans = w2 * h2
print(ans if ans > 0 else 0)
``` | instruction | 0 | 19,278 | 23 | 38,556 |
No | output | 1 | 19,278 | 23 | 38,557 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64
Submitted Solution:
```
w,h,n=map(int,input().split())
xl=0
xr=w
yu=h
ys=0
for i in range(n):
x,y,a=map(int,input().split())
if a==1:
xl=x
elif a==2:
xr=x
elif a==3:
ys=y
elif a==4:
yu=y
if (yu-ys)*(xr-xl)>=0:
print((yu-ys)*(xr-xl))
else:
print(0)
``` | instruction | 0 | 19,279 | 23 | 38,558 |
No | output | 1 | 19,279 | 23 | 38,559 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64
Submitted Solution:
```
# 63 B - すぬけ君の塗り絵 2 イージー
W,H,N = map(int,input().split())
X = []
Y = []
A = []
for _ in range(N):
x,y,a = map(int,input().split())
x -= 1;y -= 1
X.append(x)
Y.append(y)
A.append(a)
mtrx = [['.']*W for _ in range(H)]
for a,(x,y) in zip(A,zip(X,Y)):
if a == 1:
for i in range(H):
for j in range(x+1):
mtrx[i][j] = '#'
if a == 2:
for i in range(H):
for j in range(x+1,W):
mtrx[i][j] = '#'
if a == 3:
for i in range(y+1):
mtrx[i] = ['#']*W
if a == 4:
for i in range(y+1,W):
mtrx[i] = ['#']*W
ans = 0
for i in range(H):
for j in range(W):
if mtrx[i][j] == '.':
ans += 1
print(ans)
``` | instruction | 0 | 19,280 | 23 | 38,560 |
No | output | 1 | 19,280 | 23 | 38,561 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).
Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:
* If a_i = 1, he painted the region satisfying x < x_i within the rectangle.
* If a_i = 2, he painted the region satisfying x > x_i within the rectangle.
* If a_i = 3, he painted the region satisfying y < y_i within the rectangle.
* If a_i = 4, he painted the region satisfying y > y_i within the rectangle.
Find the area of the white region within the rectangle after he finished painting.
Constraints
* 1 ≦ W, H ≦ 100
* 1 ≦ N ≦ 100
* 0 ≦ x_i ≦ W (1 ≦ i ≦ N)
* 0 ≦ y_i ≦ H (1 ≦ i ≦ N)
* W, H (21:32, added), x_i and y_i are integers.
* a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4.
Input
The input is given from Standard Input in the following format:
W H N
x_1 y_1 a_1
x_2 y_2 a_2
:
x_N y_N a_N
Output
Print the area of the white region within the rectangle after Snuke finished painting.
Examples
Input
5 4 2
2 1 1
3 3 4
Output
9
Input
5 4 3
2 1 1
3 3 4
1 4 2
Output
0
Input
10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
Output
64
Submitted Solution:
```
W, H, N = map(int, input().split(' '))
minx = 0
maxx = W
miny = 0
maxy = H
for i in range(N):
x, y, a = map(int, input().split(' '))
if a == 1:
minx = max(minx, x)
elif a == 2:
maxx = min(maxx, x)
elif a == 3:
miny = max(miny, y)
else:
maxy = min(maxy, y)
if minx <= maxx and miny <= maxy:
print((maxx-minx) * (maxy-miny))
else:
print(0)
``` | instruction | 0 | 19,281 | 23 | 38,562 |
No | output | 1 | 19,281 | 23 | 38,563 |
Provide a correct Python 3 solution for this coding contest problem.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A | instruction | 0 | 19,282 | 23 | 38,564 |
"Correct Solution:
```
def solve():
line = input()
while True:
surface = list(map(int, line))
for _ in range(7):
surface.extend(map(int, input()))
for i, v in enumerate(surface):
if not v == 1:
continue
# A
if i+9 < 64 and surface[i+1] == 1 and surface[i+8] == 1 and surface[i+9] == 1:
print('A')
break
# B
if i+24 < 64 and surface[i+24] == 1:
print('B')
break
# C
if surface[i+3] == 1:
print('C')
break
# D
if i+15 < 64 and surface[i+15] == 1:
print('D')
break
# E
if i+10 < 64 and surface[i+10] == 1:
print('E')
break
# F
if i+17 < 64 and surface[i+17] == 1:
print('F')
break
# G
if surface[i+1] == 1 and surface[i+7] == 1 and surface[i+8] == 1:
print('G')
break
try:
input()
line = input()
except EOFError:
break
if __name__ == "__main__":
solve()
``` | output | 1 | 19,282 | 23 | 38,565 |
Provide a correct Python 3 solution for this coding contest problem.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A | instruction | 0 | 19,283 | 23 | 38,566 |
"Correct Solution:
```
# Aizu Problem 0036: Figure on Surface
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def get_figure(figure):
for frow in range(8):
if '1' in figure[frow]:
fcol = figure[frow].find('1')
break
figure = figure[frow:]
frow = 0
ones = []
min_col = 9
for row in range(len(figure)):
for col in range(8):
if figure[row][col] == '1':
ones.append([row, col])
min_col = min(min_col, col)
for k in range(len(ones)):
ones[k][1] -= min_col
if ones == [[0, 0], [0, 1], [1, 0], [1, 1]]:
return 'A'
elif ones == [[0, 0], [1, 0], [2, 0], [3, 0]]:
return 'B'
elif ones == [[0, 0], [0, 1], [0, 2], [0, 3]]:
return 'C'
elif ones == [[0, 1], [1, 0], [1, 1], [2, 0]]:
return 'D'
elif ones == [[0, 0], [0, 1], [1, 1], [1, 2]]:
return 'E'
elif ones == [[0, 0], [1, 0], [1, 1], [2, 1]]:
return 'F'
elif ones == [[0, 1], [0, 2], [1, 0], [1, 1]]:
return 'G'
else:
return '?'
while True:
figure = [input().strip() for _ in range(8)]
print(get_figure(figure))
try:
dummy = input()
except EOFError:
break
``` | output | 1 | 19,283 | 23 | 38,567 |
Provide a correct Python 3 solution for this coding contest problem.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A | instruction | 0 | 19,284 | 23 | 38,568 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
import os
d = {}
d['A'] = ['11', '11']
d['B'] = ['1', '1', '1', '1']
d['C'] = ['1111']
d['D'] = ['01', '11', '10']
d['E'] = ['110', '011']
d['F'] = ['10', '11', '01']
d['G'] = ['011', '110']
DEBUG = False
A = []
for s in sys.stdin:
s = s.strip()
if s == '':
continue
A.append(s)
if len(A) == 8:
# solve
# ...
answer = None
for key in d.keys():
figure = d[key]
W = len(figure[0])
H = len(figure)
for x in range(8 - W + 1):
for y in range(8 - H + 1):
# check
is_fit = True
for i, row in enumerate(figure):
if not row == A[y+i][x:x+W]:
is_fit = False
break
if is_fit:
if DEBUG:
print()
print('all fit', key)
print('A', A)
print('x, y', x, y)
print('W, H', W, H)
print('figure', figure)
answer = key
print(answer)
A = []
``` | output | 1 | 19,284 | 23 | 38,569 |
Provide a correct Python 3 solution for this coding contest problem.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A | instruction | 0 | 19,285 | 23 | 38,570 |
"Correct Solution:
```
#"1"の座標を、最初のものを(0,0)として切り出し
def trim(mp):
ret = []
for x in range(8):
for y in range(8):
if mp[y][x] == "1":
if not ret:
refer = (x, y)
ret.append((x, y))
ret = [(x - refer[0], y - refer[1]) for x, y in ret]
return ret
#座標が一致したものを出力
def put_ans(points):
if points == [(0, 0), (0, 1), (1, 0), (1, 1)]: print("A")
if points == [(0, 0), (0, 1), (0, 2), (0, 3)]: print("B")
if points == [(0, 0), (1, 0), (2, 0), (3, 0)]: print("C")
if points == [(0, 0), (0, 1), (1, -1), (1, 0)]: print("D")
if points == [(0, 0), (1, 0), (1, 1), (2, 1)]: print("E")
if points == [(0, 0), (0, 1), (1, 1), (1, 2)]: print("F")
if points == [(0, 0), (1, -1), (1, 0), (2, -1)]: print("G")
while True:
mp = [input() for _ in range(8)]
put_ans(trim(mp))
try:
input()
except EOFError:
break
``` | output | 1 | 19,285 | 23 | 38,571 |
Provide a correct Python 3 solution for this coding contest problem.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A | instruction | 0 | 19,286 | 23 | 38,572 |
"Correct Solution:
```
while True:
try:
x=[[int(i) for i in input()] for j in range(8)]
count=0
num=[]
for i in range(8):
if x[i].count(1)!=0:
num.append(i)
count+=1
if count==1:
print("C")
elif count==4:
print("B")
elif count==2:
for j in range(8):
if x[num[0]][j]==1:
if j==0:
if x[num[0]+1][j]==1:
print("A")
else:
print("E")
else:
if x[num[0]+1][j-1]==1:
print("G")
else:
if x[num[0]+1][j]==1:
print("A")
else:
print("E")
break
else:
for j in range(8):
if x[num[0]][j]==1:
if j==0:
print("F")
else:
if x[num[0]+1][j-1]==1:
print("D")
else:
print("F")
break
input()
except EOFError:
break
``` | output | 1 | 19,286 | 23 | 38,573 |
Provide a correct Python 3 solution for this coding contest problem.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A | instruction | 0 | 19,287 | 23 | 38,574 |
"Correct Solution:
```
Figures = {"A": [[0, 1], [1, 0], [1, 1]],
"B": [[1, 0], [2, 0], [3, 0]],
"C": [[0, 1], [0, 2], [0, 3]],
"D": [[1, -1], [1, 0], [2, -1]],
"E": [[0, 1], [1, 1], [1, 2]],
"F": [[1, 0], [1, 1], [2, 1]],
"G": [[0, 1], [1, -1], [1, 0]]}
while True:
try:
k = [map(int, list(input())) for i in range(8)]
l = [[y, x] for y,q in enumerate(k) for x,t in enumerate(q) if t]
a, b = l[0]
for i in range(4):
l[i][0] -= a
l[i][1] -= b
for k, v in Figures.items():
if l[1:] == v:
print(k)
break
input()
except:
break
``` | output | 1 | 19,287 | 23 | 38,575 |
Provide a correct Python 3 solution for this coding contest problem.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A | instruction | 0 | 19,288 | 23 | 38,576 |
"Correct Solution:
```
ans = [0,0,0,"C",0,0,0,0,"G","A","E",0,0,0,0,"D",0,"F",0,0,0,0,0,0,"B"]
while(True):
h = ""
for _ in range(8):
h +=input()
print(ans[h.rfind("1")-h.find("1")])
try:
b =input()
except:
break
``` | output | 1 | 19,288 | 23 | 38,577 |
Provide a correct Python 3 solution for this coding contest problem.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A | instruction | 0 | 19,289 | 23 | 38,578 |
"Correct Solution:
```
while 1:
a=[list(map(int,input()))for _ in[0]*8]
y=[sum(r)for r in a]
x=[sum(c)for c in zip(*a)]
if 4 in x:print('B')
elif 4 in y:print('C')
elif 1 in y:print('DF'[a[y.index(1)][x.index(2)]])
elif 1 in x:print('GE'[a[y.index(2)][x.index(1)]])
else:print('A')
try:input()
except:break
``` | output | 1 | 19,289 | 23 | 38,579 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A
Submitted Solution:
```
# AOJ 0036: A Figure on Surface
# Python3 2018.6.27 bal4u
def judge(sr, sc, tbl):
if 4 in sr: return 'C'
if 4 in sc: return 'B'
if 1 in sr: return 'F' if tbl[sr.index(1)][sc.index(2)] == 1 else 'D'
if 1 in sc: return 'E' if tbl[sr.index(2)][sc.index(1)] == 1 else 'G'
return 'A'
tbl = [[] for i in range(8)]
while True:
for r in range(8): tbl[r] = list(map(int, input()))
sr, sc = [0]*8, [0]*8
for i in range(8): sr[i] = sum(tbl[i])
for i in range(8): sc[i] = sum([tbl[r][i] for r in range(8)])
print(judge(sr, sc, tbl))
try: input()
except: break
``` | instruction | 0 | 19,290 | 23 | 38,580 |
Yes | output | 1 | 19,290 | 23 | 38,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A
Submitted Solution:
```
import sys
line=[]
in_line=sys.stdin
for _in in in_line:line.append(_in)
#for i in range(89):line.append(input())
sets=(len(line)+1)//9
for i in range(sets):
flag=0
topindex=-1
for j in range(i*9,i*9+9):
a=line[j].count('1')
if a!=0:t=line[j].index('1')
else:t=-1
if a==4:
print('C')
break
elif flag==0 and a!=0:
topindex=t
if a==1:flag=1
elif a==2:flag=2
elif flag==1:
if a==1:
print('B')
break
elif a==2:
if topindex==t:
print('F')
break
else:
print('D')
break
elif flag==2:
if topindex==t:
print('A')
break
elif topindex<t:
print('E')
break
else:
print('G')
break
``` | instruction | 0 | 19,291 | 23 | 38,582 |
Yes | output | 1 | 19,291 | 23 | 38,583 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A
Submitted Solution:
```
A=[[0,0],[1,0],[0,1],[1,1]]
B=[[0,0],[0,1],[0,2],[0,3]]
C=[[0,0],[1,0],[2,0],[3,0]]
D=[[0,0],[-1,1],[0,1],[-1,2]]
E=[[0,0],[1,0],[1,1],[2,1]]
F=[[0,0],[0,1],[1,1],[1,2]]
G=[[0,0],[1,0],[-1,1],[0,1]]
humen=[]
gentenx="0"
genteny="0"
kigou=[]
ans=[]
s=""
while(1):
if len(humen)>=8:
for y in range(0,8):#y
for x in range(0,8):#x
if humen[y][x]=="1" and gentenx=="0" and genteny=="0":#位置記憶
gentenx=x
genteny=y
kigou.append([0,0])
elif humen[y][x]=="1" :
kigou.append([x-gentenx,y-genteny])
if A==kigou:ans.append("A")
if B==kigou:ans.append("B")
if C==kigou:ans.append("C")
if D==kigou:ans.append("D")
if E==kigou:ans.append("E")
if F==kigou:ans.append("F")
if G==kigou:ans.append("G")
kigou=[]
humen=[]
gentenx="0"
genteny="0"
try: s=str(input(""))
except:break
if s!="":humen.append(list(s))
for i in ans:
print(i)
``` | instruction | 0 | 19,292 | 23 | 38,584 |
Yes | output | 1 | 19,292 | 23 | 38,585 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A
Submitted Solution:
```
import sys
f = sys.stdin
figures = {'A':['11','11'],
'B':['1','1','1','1'],
'C':['1111'],
'D':['01','11','10'],
'E':['110','011'],
'F':['10','11','01'],
'G':['011','110']}
def figure_in_board(figure, board):
for i in range(len(board)):
index = board[i].find(figure[0])
if index != -1 and i + len(figure) <= len(board):
for j in range(1, len(figure)):
if index != board[i + j].find(figure[j]):
return False
return True
return False
while True:
board = [f.readline().strip() for _ in range(8)]
for k, v in figures.items():
if figure_in_board(v, board):
print(k)
break
if f.readline() == '':
break
``` | instruction | 0 | 19,293 | 23 | 38,586 |
Yes | output | 1 | 19,293 | 23 | 38,587 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A
Submitted Solution:
```
def main():
while True:
try:
Array = []
for _ in range(8):
Array.append(list(map(int,input().strip())))
if 1 not in Array[-1]:
Array.pop()
if len(Array) == 1:
print('C')
elif len(Array) == 2:
if Array[0].index(1) == Array[1].index(1):
print('A')
elif Array[0].index(1) < Array[1].index(1):
print('E')
else:
print('G')
elif len(Array) == 3:
if Array[0].index(1) > Array[2].index(1):
print('D')
else:
print('F')
else:
print('B')
except EOFError:
break
if __name__ == '__main__':
main()
``` | instruction | 0 | 19,294 | 23 | 38,588 |
No | output | 1 | 19,294 | 23 | 38,589 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A
Submitted Solution:
```
while True:
try:
lst = []
for i in range(8):
lst += list(map(int, input()))
cnt = 0
for i in range(len(lst)):
if lst[i]:
cnt += i
cnt -= lst.index(1) * 4
if cnt == 18:
ans = "A"
elif cnt == 48:
ans = "B"
elif cnt == 6:
ans = "C"
elif cnt == 34:
ans = "D"
elif cnt == 20:
ans = "E"
elif cnt == 34:
ans = "F"
else:
ans = "G"
print(ans)
except:
break
``` | instruction | 0 | 19,295 | 23 | 38,590 |
No | output | 1 | 19,295 | 23 | 38,591 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A
Submitted Solution:
```
while True:
try:
x=[[int(i) for i in input()] for j in range(8)]
count=0
num=[]
for i in range(8):
if x[i].count(1)!=0:
num.append(i)
count+=1
if count==1:
print("C")
elif count==4:
print("B")
elif count==2:
for j in range(8):
if x[num[0]][j]==1:
if j==0:
if x[num[0]+1][j]==1:
print("A")
else:
print("E")
else:
if x[num[0]+1][j-1]==1:
print("G")
else:
if x[num[0]+1][j]==1:
print("A")
else:
print("E")
break
else:
for j in range(8):
if x[num[0]][j]==1:
if j==0:
print("F")
else:
if x[num[0]][j-1]==1:
print("D")
else:
print("F")
break
except EOFError:
break
``` | instruction | 0 | 19,296 | 23 | 38,592 |
No | output | 1 | 19,296 | 23 | 38,593 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 1
---
Only one of the following A to G shapes is placed on this plane.
| A
---
■| ■| |
--- | --- | --- | ---
■| ■| |
| | |
| | |
| B
---
| ■| |
--- | --- | --- | ---
| ■| |
| ■| |
| ■| |
| C
---
■| ■| ■| ■
--- | --- | --- | ---
| | |
| | |
| | |
| D
---
| ■| |
--- | --- | --- | ---
■| ■| |
■ | | |
| | |
| E
---
■| ■| |
--- | --- | --- | ---
| ■| ■|
| | |
| | |
| F
---
■ | | |
--- | --- | --- | ---
■| ■| |
| ■| |
| | |
| G
---
| ■| ■|
--- | --- | --- | ---
■| ■| |
| | |
| | |
For example, in the example in Figure 2 below, the shape E is placed.
| □ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | ■| ■| □ | □ | □ | □ | □
□ | □ | ■| ■| □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
Figure 2
---
Create a program that reads a sequence of numbers that expresses the squares occupied by figures by 1 and the cells that do not occupy 0 in the plane, and outputs the types (A to G) of the placed figures. ..
However, there is always one figure placed on one plane, and multiple figures cannot be placed. In addition, there is nothing other than the figures represented by A to G.
Input
The input consists of multiple datasets.
One dataset is given eight strings of eight characters, with the squares occupied by the shape in the plane represented by 1 and the squares not occupied by 0 represented by 0. For example, the sequence of strings corresponding to Figure 2 is as follows:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 1 | 1 | 0 | 0 | 0 | 0 | 0
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
The datasets are separated by a single blank line. The number of datasets does not exceed 50.
Output
For each data set, output the type of figure (any of A to G) given to the plane on one line.
Example
Input
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000
00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000
Output
E
C
A
Submitted Solution:
```
ans = {"1100000011": "A", "1000000010000000100000001": "B",
"1111": "C", "1000000110000001": "D",
"11000000011": "E", "100000001100000001": "F", "0110000011": "G"}
while True:
try:
st = ""
for i in range(8):
st += input()
for k, v in ans.items():
if st.find(k) != -1:
print(v)
break
except:
break
``` | instruction | 0 | 19,297 | 23 | 38,594 |
No | output | 1 | 19,297 | 23 | 38,595 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner.
Three friends, Alice, Bob, and Charlie are going to buy three distinct plots of land A, B, C in the forest. Initially, all plots in the forest (including the plots A, B, C) are covered by trees. The friends want to visit each other, so they want to clean some of the plots from trees. After cleaning, one should be able to reach any of the plots A, B, C from any other one of those by moving through adjacent cleared plots. Two plots are adjacent if they share a side.
<image> For example, A=(0,0), B=(1,1), C=(2,2). The minimal number of plots to be cleared is 5. One of the ways to do it is shown with the gray color.
Of course, the friends don't want to strain too much. Help them find out the smallest number of plots they need to clean from trees.
Input
The first line contains two integers x_A and y_A — coordinates of the plot A (0 ≤ x_A, y_A ≤ 1000). The following two lines describe coordinates (x_B, y_B) and (x_C, y_C) of plots B and C respectively in the same format (0 ≤ x_B, y_B, x_C, y_C ≤ 1000). It is guaranteed that all three plots are distinct.
Output
On the first line print a single integer k — the smallest number of plots needed to be cleaned from trees. The following k lines should contain coordinates of all plots needed to be cleaned. All k plots should be distinct. You can output the plots in any order.
If there are multiple solutions, print any of them.
Examples
Input
0 0
1 1
2 2
Output
5
0 0
1 0
1 1
1 2
2 2
Input
0 0
2 0
1 1
Output
4
0 0
1 0
1 1
2 0
Note
The first example is shown on the picture in the legend.
The second example is illustrated with the following image:
<image> | instruction | 0 | 19,453 | 23 | 38,906 |
Tags: implementation, math
Correct Solution:
```
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
c = tuple(map(int, input().split()))
todig = []
p = [a, b, c]
p.sort(key=lambda x:x[0])
m = p[1]
min_1 = min(a[1], b[1], c[1])
max_1 = max(a[1], b[1], c[1])
for i in range(min_1, max_1+1):
todig.append((m[0], i))
for d in p:
if d != m:
for i in range(m[0], d[0]+1):
todig.append((i, d[1]))
for i in range(d[0], m[0]+1):
todig.append((i, d[1]))
todig = set(todig)
print(len(todig))
for i in todig:
print('{} {}'.format(i[0],i[1]))
``` | output | 1 | 19,453 | 23 | 38,907 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner.
Three friends, Alice, Bob, and Charlie are going to buy three distinct plots of land A, B, C in the forest. Initially, all plots in the forest (including the plots A, B, C) are covered by trees. The friends want to visit each other, so they want to clean some of the plots from trees. After cleaning, one should be able to reach any of the plots A, B, C from any other one of those by moving through adjacent cleared plots. Two plots are adjacent if they share a side.
<image> For example, A=(0,0), B=(1,1), C=(2,2). The minimal number of plots to be cleared is 5. One of the ways to do it is shown with the gray color.
Of course, the friends don't want to strain too much. Help them find out the smallest number of plots they need to clean from trees.
Input
The first line contains two integers x_A and y_A — coordinates of the plot A (0 ≤ x_A, y_A ≤ 1000). The following two lines describe coordinates (x_B, y_B) and (x_C, y_C) of plots B and C respectively in the same format (0 ≤ x_B, y_B, x_C, y_C ≤ 1000). It is guaranteed that all three plots are distinct.
Output
On the first line print a single integer k — the smallest number of plots needed to be cleaned from trees. The following k lines should contain coordinates of all plots needed to be cleaned. All k plots should be distinct. You can output the plots in any order.
If there are multiple solutions, print any of them.
Examples
Input
0 0
1 1
2 2
Output
5
0 0
1 0
1 1
1 2
2 2
Input
0 0
2 0
1 1
Output
4
0 0
1 0
1 1
2 0
Note
The first example is shown on the picture in the legend.
The second example is illustrated with the following image:
<image> | instruction | 0 | 19,454 | 23 | 38,908 |
Tags: implementation, math
Correct Solution:
```
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
# base 1
base1 = {(x1, y1)}
for i in range(min(x2, x1), max(x2, x1) + 1):
base1.add((i, y1))
for i in range(min(x3, x1), max(x3, x1) + 1):
base1.add((i, y1))
for i in range(min(y2, y1), max(y2, y1) + 1):
base1.add((x2, i))
for i in range(min(y3, y1), max(y3, y1) + 1):
base1.add((x3, i))
# base 2
base2 = {(x2, y2)}
for i in range(min(x2, x1), max(x2, x1) + 1):
base2.add((i, y2))
for i in range(min(x3, x2), max(x3, x2) + 1):
base2.add((i, y2))
for i in range(min(y2, y1), max(y2, y1) + 1):
base2.add((x1, i))
for i in range(min(y3, y2), max(y3, y2) + 1):
base2.add((x3, i))
# base 3
base3 = {(x2, y2)}
for i in range(min(x3, x1), max(x3, x1) + 1):
base3.add((i, y3))
for i in range(min(x3, x2), max(x3, x2) + 1):
base3.add((i, y3))
for i in range(min(y3, y1), max(y3, y1) + 1):
base3.add((x1, i))
for i in range(min(y3, y2), max(y3, y2) + 1):
base3.add((x2, i))
ans = {}
if len(base1) < len(base2):
ans = base1
else:
ans = base2
if len(ans) > len(base3):
ans = base3
print(len(ans))
for i in ans:
print(*i)
``` | output | 1 | 19,454 | 23 | 38,909 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner.
Three friends, Alice, Bob, and Charlie are going to buy three distinct plots of land A, B, C in the forest. Initially, all plots in the forest (including the plots A, B, C) are covered by trees. The friends want to visit each other, so they want to clean some of the plots from trees. After cleaning, one should be able to reach any of the plots A, B, C from any other one of those by moving through adjacent cleared plots. Two plots are adjacent if they share a side.
<image> For example, A=(0,0), B=(1,1), C=(2,2). The minimal number of plots to be cleared is 5. One of the ways to do it is shown with the gray color.
Of course, the friends don't want to strain too much. Help them find out the smallest number of plots they need to clean from trees.
Input
The first line contains two integers x_A and y_A — coordinates of the plot A (0 ≤ x_A, y_A ≤ 1000). The following two lines describe coordinates (x_B, y_B) and (x_C, y_C) of plots B and C respectively in the same format (0 ≤ x_B, y_B, x_C, y_C ≤ 1000). It is guaranteed that all three plots are distinct.
Output
On the first line print a single integer k — the smallest number of plots needed to be cleaned from trees. The following k lines should contain coordinates of all plots needed to be cleaned. All k plots should be distinct. You can output the plots in any order.
If there are multiple solutions, print any of them.
Examples
Input
0 0
1 1
2 2
Output
5
0 0
1 0
1 1
1 2
2 2
Input
0 0
2 0
1 1
Output
4
0 0
1 0
1 1
2 0
Note
The first example is shown on the picture in the legend.
The second example is illustrated with the following image:
<image> | instruction | 0 | 19,455 | 23 | 38,910 |
Tags: implementation, math
Correct Solution:
```
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
k=max(y1,y2,y3)+1-min(y1,y2,y3)+max(x1,x2,x3)-min(x1,x2,x3)
m=[0,y1,y2,y3]
m.sort()
z=[0,x1,x2,x3]
z.sort()
print(k)
for i in range(z[1],z[3]+1):
print(str(i)+' '+str(m[2]))
for i in range(m[2]+1,m[3]+1):
if m[3]==y3:
print(str(x3)+' '+str(i))
if m[3]==y2:
print(str(x2)+' '+str(i))
if m[3]==y1:
print(str(x1)+' '+str(i))
for i in range(m[1],m[2]):
if m[1]==y3:
print(str(x3)+' '+str(i))
if m[1]==y2:
print(str(x2)+' '+str(i))
if m[1]==y1:
print(str(x1)+' '+str(i))
``` | output | 1 | 19,455 | 23 | 38,911 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.