Skip to content

Commit 1e7ff92

Browse files
Merge pull request #7 from tinyCodersDen/master
Add 2024 CCC Senior Contest Solutions
2 parents e9eea18 + 327aee0 commit 1e7ff92

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

2024/Python/Senior Problems/S1.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
N = int(input())
2+
t = N//2
3+
l = []
4+
for a in range(N):
5+
l.append(int(input()))
6+
7+
ans = 0
8+
for y in range(len(l)//2):
9+
if l[y] == l[y+t]:
10+
ans+=2
11+
print(ans)

2024/Python/Senior Problems/S2.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
for h in range(T):
2+
j = input()
3+
d = {}
4+
for t in j:
5+
if t in d.keys():
6+
d[t] += 1
7+
else:
8+
d[t] = 1
9+
if d[j[0]] == 1:
10+
b = False
11+
for t in range(0,len(j),2):
12+
if d[j[t]]!=1:
13+
b = True
14+
print('F')
15+
break
16+
if not b:
17+
b = False
18+
for t in range(1,len(j),2):
19+
if d[j[t]]<2:
20+
b = True
21+
print('F')
22+
break
23+
if not b:
24+
print("T")
25+
elif d[j[0]]>1:
26+
b = False
27+
for t in range(0,len(j),2):
28+
if d[j[t]]<2:
29+
b = True
30+
print('F')
31+
break
32+
if not b:
33+
b = False
34+
for t in range(1,len(j),2):
35+
if d[j[t]]!=1:
36+
b = True
37+
print('F')
38+
break
39+
if not b:
40+
print("T")

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)