[Codeforces] Unknown Language Round 2 E. Ali goes shopping

Unknown Language Round 2 E. Ali goes shopping

  • Time :
  • Space :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
s := File standardInput readLine
L := s size
sol := ""
solr := -1
for(i, 0, L-1,
for(j, i, L-1,
t := s slice(i, j+1)
l := t size
r := 0
for(k, 0, L-l,
if(t == s slice(k, k+l), r = r + 1)
)
if(r > solr,
solr = r
sol = t,
if(r == solr,
if(sol size < l,
solr = r
sol = t,
if(sol size == l and sol < t,
solr = r
sol = t
)
)
)
)
)
)
sol println
Author: Song Hayoung
Link: https://songhayoung.github.io/2023/06/21/PS/Codeforces/unknown-language-round-2-e/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.