n = int(input())
def compare(a,b):
sus = 0
for i in range(min(len(a),len(b))):
if a[i]==b[i]:
sus += 1
else:
break
return sus
words = dict()
for i in range(n):
words[input()] = 0
maxi = ""
for i in words:
if len(i) > len(maxi):
maxi = i
suswords = dict()
for i in words:
words[i] = compare(i, maxi)
lis = [i for i in words]
lis.sort(key=lambda x: (words[x], x))
ans = 1
cur = []
for i in range(len(lis)-1):
for j in lis[i][len(cur):]:
cur.append(j)
ans += 1
ans += 1
for i in lis[i][compare(lis[i], lis[i+1]):][::-1]:
ans += 1
cur.pop()
for j in lis[-1][len(cur):]:
ans += 1
print(ans)
cur = []
for i in range(len(lis)-1):
for j in lis[i][len(cur):]:
cur.append(j)
print(j)
print("P")
for i in lis[i][compare(lis[i], lis[i+1]):][::-1]:
print("-")
cur.pop()
for j in lis[-1][len(cur):]:
print(j)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
18200 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
18232 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
18272 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
18232 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
70 ms |
19688 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
128 ms |
26348 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
181 ms |
28164 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
262 ms |
28028 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
379 ms |
29116 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
399 ms |
30272 KB |
Line "" doesn't correspond to pattern "[a-z\-P]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |