Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Minimal Rotation -CSES String Problem

Правка en1, от Archade_123, 2023-09-11 05:08:57

The code is working for all testcases except bbaabbabaa can you please suggest where is the mistake. Input-:bbaabbabaa **** Correct Output -: aabbaabbab Code Output-:aabbabaabb

void solve(){ string str; cin>>str; str+=str; int n = str.size(); int i = 0; int ans = 0; while (i < n/2) { ans = i; int k = i, j = i + 1; while (j < n && s[j] >= s[k]) { if (str[j] == str[k]) k++; if (str[j] > str[k] ) k = i; j++; } while(i <= k) i += j — k; } cout<<s.substr(ans,n/2); }

Теги string, cses

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Archade_123 2023-09-11 05:10:25 48
en2 Английский Archade_123 2023-09-11 05:09:33 12 (published)
en1 Английский Archade_123 2023-09-11 05:08:57 719 Initial revision (saved to drafts)