1 solutions

  • 0
    @ 2025-11-5 15:20:31

    Pascal :

    var str:ansistring;
        n,i,j,sum,ans:longint;
    begin
      
      readln(n);
      readln(str);
      str:=str+str+str;
      ans:=0;
      for i:=n+1 to n+n do
      begin
        sum:=0;
        for j:=i downto 1 do
          if (str[i]=str[j]) or (str[j]='w') then
            else break;
        sum:=i-j;
        for j:=i+1 to n+n+n do
          if (str[i]=str[j]) or (str[j]='w') then
            else break;
        sum:=sum+j-i;
        if sum>ans then ans:=sum;
      end;
      writeln(ans);
      
    end.
    
    • 1

    Information

    ID
    16675
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By