CodeForces Group Link: https://mirror.codeforces.com/group/0jQZ3oBvJG
Problem A
Problem Author: jothin
"lesser the age gap between two people, higher the interaction between them" so we need to find the first neighbour pair with the lowest age gap
n=int(input())
A=[int(x) for x in input().split()]
from itertools import pairwise
req=min(abs(x-y) for x,y in pairwise(A))
for i in range(n-1):
if abs(A[i]-A[i+1])==req:
print(i+1)
break
Problem B
Problem Author: jothin
he gets the verdict "Wrong answer on test k"
So, he knows the correct answer for the first k-1 test cases and also he knows the wrong answer for the test case k. The opposite of his current answer for test case k will be the correct answer. Hence, he now knows the correct answer for the first k test cases
There are m-k test cases remaining. In the worst case scenario, all of his initial guesses would be incorrect. Hence he will get m-k more WAs
He initially got a WA. So, in total he got m-k+1 WA
m,k=map(int,input().split())
print(m-k+1)
Problem C
Problem Author: jothin
TLDR: the edge case is 2028
If x%4=1, that year's batch will be assigned hostel A
If x%4=2, that year's batch will be assigned hostel B
If x%4=3, that year's batch will be assigned hostel C
If x%4=0, that year's batch will be assigned hostel D
Since there are 50 students per floor,
In 2025 ground floor and 1st floor occupied (2 floors in total)
In 2026 ground floor to 2nd floor occupied (3 floors in total)
In 2027 ground floor to 3rd floor occupied (4 floors in total)
In year x, ground floor to (x-2024)th floor occupied (x-2023 floors in total)
If x%4=1, first floor is guaranteed to be occupied. So answer will be 1/(x-2023)
If x%4=2, ground floor is guaranteed to be occupied. So answer will be 1/(x-2023)
If x%4=3, ground and first floor are both guaranteed to be occupied. So answer will be 2/(x-2023)
If x%4=0 and x>2028, first, third and fifth floors are guaranteed to be occupied. So answer will be 3/(x-2023)
If x%4=0 and x=2028, fifth floor will not be occupied but first and third floors will be occupied. So, answer will be 2/5
Kindly note the given output format in the problem
from math import gcd
for _ in range(1):
x=int(input())
if x==2028:
print("2 5")
continue
b=x-2023
if x%4==1:
a=1
elif x%4==2:
a=1
elif x%4==3:
a=2
else:
a=3
g=gcd(a,b)
a//=g
b//=g
print(a,b)
Problem D
Problem Author: KartikManmode
Editorial for this problem will be out soon
Problem E
Problem Author: jothin
By replacing exactly one bead, we can create one beautiful necklace
For the cases where we should replace exactly 2 beads, first let's pick an arbitrary white bead and replace it with a red bead. Now, two configurations will be different iff the minimum distance between the two beads are different in the two configurations.
If n is even, the first choosen bead has an opposite bead. we can start from either neighbours of the initial bead and go step by step till that opposite bead. Each of them will represent a distinct configuration since the minimum distance is just the path traced. So, there will be n/2 possible configurations with 2 beads being replaced
If n is odd, there is no opposite bead. But now, if we cut the necklace at the string opposite to the initial bead, there are exactly (n-1)/2 beads on either sides of the initial bead and they're all guaranteed to be the minimum distance. Hence, the answer will be (n-1)/2
So, the final answer will be 1+(n/2) if n is even else 1+(n-1)/2
for _ in range(int(input())):
n=int(input())
print(1+n//2)
Problem F
Problem Author: sharkie1604
To achieve the optimal $$$O(N)$$$ solution, we must look at the mathematical properties of the merges by assigning $$$C = 1$$$ and $$$A = 2$$$. The two valid operations are $$$CC \to A$$$ (changing the sum by $$$1+1 \to 2$$$, a difference of $$$0$$$) and $$$AA \to C$$$ (changing the sum by $$$2+2 \to 1$$$, a difference of $$$-3$$$). Because these moves only ever change the total sum by a multiple of 3, the sum of the string modulo 3 is a strict invariant. The winning states of a single $$$C$$$ or $$$A$$$ have modulo values of $$$1$$$ and $$$2$$$. Therefore, if a string's initial total sum evaluates to $$$0 \pmod 3$$$, it is mathematically impossible to reach a winning state, and the answer is NO.However, even if the math permits a win, we must check if we are physically trapped. A perfectly alternating string (like ACACACA) has no adjacent identical potions, meaning no moves can be made at all. Therefore, the complete $$$O(N)$$$ logic is: if the string is length $$$1$$$, print YES. Otherwise, if it does not contain CC and does not contain AA, print NO (the alternating trap). If it escapes the trap, calculate the total value (Count of C * 1) + (Count of A * 2). If this value modulo 3 is 0, print NO; otherwise, print YES.
t = int(input())
for _ in range(t):
s = input().strip()
n = len(s)
if n == 1:
print("YES")
continue
if "CC" not in s and "AA" not in s:
print("NO")
continue
count_C = s.count('C')
count_A = n - count_C
total_val = count_C + (count_A * 2)
if total_val % 3!=0:
print("YES")
else:
print("NO")
Other notes
All solutions and codes are provided by the respective problem's author
We have received feedback about problem E being easier than A. I acknowledge the error on my end. Any inconvenience caused is regretted. We have requested our college management additional on site slots to ensure fairness.
Hope everyone enjoyed rest of the problems!
UPD1: added solution and code for problem F




