Skip to content

Commit 327aee0

Browse files
Add 2024 CCC Senior Solutions
Adding all the recent CCC Senior Solutions for last year's contest.
1 parent c039477 commit 327aee0

File tree

1 file changed

+71
-0
lines changed
  • 2024/Python/Senior Problems

1 file changed

+71
-0
lines changed

2024/Python/Senior Problems/S3.py

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This submission yields 4/15 points
2+
import copy
3+
N = int(input())
4+
5+
a = list(map(int,input().split(' ')))
6+
b = list(map(int,input().split(' ')))
7+
8+
if N==2:
9+
if (a[0] not in b) and (a[1] not in b):
10+
print("NO")
11+
else:
12+
if a[0] == b[1] and a[1] == b[0] and a!=b:
13+
print("NO")
14+
elif (b[0] not in a) or (b[1] not in a):
15+
print("NO")
16+
else:
17+
print("YES")
18+
if set(a) == set(b):
19+
print(0)
20+
else:
21+
print('1')
22+
if a[0] in b:
23+
print('R 0 1')
24+
elif a[1] in b:
25+
print('L 0 1')
26+
else:
27+
if a == b:
28+
print("YES")
29+
print(0)
30+
else:
31+
z = False
32+
for f in b:
33+
if f not in a:
34+
print("NO")
35+
z = True
36+
break
37+
if not z:
38+
i = 0
39+
ans = []
40+
for e in range(len(a)):
41+
if a[e] != b[e]:
42+
z = False
43+
for q in range(e+1,len(a)):
44+
if a[e:q][::-1] == b[e:q]:
45+
z = True
46+
break
47+
if z:
48+
print("NO")
49+
break
50+
if not z:
51+
if a[e-1] == b[e-1] and a[e-1] == b[e] and e!=0:
52+
for q in range(e,len(a)):
53+
if b[q] != b[e-1]:
54+
q-=1
55+
break
56+
a[q] = a[e-1]
57+
ans.append("R "+str(e-1)+" "+str(q))
58+
i+=1
59+
else:
60+
for q in range(e,len(a)):
61+
if a[q] == b[q]:
62+
break
63+
for w in range(q,e-1,-1):
64+
a[w] = copy.copy(a[q])
65+
ans.append("L "+str(e)+" "+str(q))
66+
i+=1
67+
if not z:
68+
print("YES")
69+
print(i)
70+
for t in ans:
71+
print(t)

0 commit comments

Comments
 (0)