-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid2.py
60 lines (40 loc) · 1.04 KB
/
grid2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
n = input().strip()
a = [int(x_temp) for x_temp in input().strip().split(' ')]
def fract(i):
d = 9
while d < i:
d = 10 * d + 9
return i / d
sorted_a = sorted(a, key=fract, reverse=True)
str_a = [str(i) for i in sorted_a]
print(''.join(str_a))
n = input().strip()
a = [int(x_temp) for x_temp in input().strip().split(' ')]
n = int(input().strip())
grid = []
sorted_grid = []
for i in range(n):
row = [i for i in input().strip()]
grid.append(row)
for i in grid:
si = sorted(i, key=ord)
sorted_grid.append(si)
val = 'YES'
for i in range(n):
col = []
col.append(sorted_grid[i][0])
sorted_col = sorted(col, key=ord)
if sorted_col == col:
pass
else:
val = 'NO'
break
print(val)
n = input().strip()
a = [int(x_temp) for x_temp in input().strip().split(' ')]
result = 0
for i, x in enumerate(a):
for j, y in enumerate(a[i + 1:]):
if ((x + y) in a):
result += 1
print(result)