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

Блог пользователя garibcoder

Автор garibcoder, история, 4 года назад, По-английски

How to solve this problem using minimum number of operations?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

Автор garibcoder, история, 4 года назад, По-английски

Can you guys help me out with the following code.On compilation it is showing segmentation fault.

int n; cin>>n; string s; cin>>s; int j=0; char c; while(s[j]&&s[j]==s[n-1]) { s.push_back(s[n-1]); j++; } int ans=0;

for(int i=j;i<s.length();i++) { int ctr=0; c=s[i]; while(s[i]&&s[i]==c) { ctr++; i++; } if(ctr>=3) ans+=ctr/3; }

cout<<ans; cout<<s; cout<<"\n";

P.S.:-This is the solution of Problem 1392D Omkar and Bed Wars recently asked in Global Codeforces round 10.Please help me:(

Полный текст и комментарии »

  • Проголосовать: нравится
  • -27
  • Проголосовать: не нравится