C - Reversible Editorial by evima

Proposer's Implementation

For each input string \(S_i\), define its standard state as the lexicographically smaller of \(S_i\) and the reversed \(S_i\). Then, you can compare the strings in their standard states.

Sample Implementation (Python)

N = int(input())
t = set()
for _ in range(N):
    S = input()
    t.add(min(S, S[::-1]))
print(len(t))

posted:
last update: