#include <stdio.h>
#include <string.h>
char c[1000000];
void nextpoli()
{
    int m,i=0,tm=0,t2=strlen(c);
    if(!((t2)&1)) {m = t2/2-1; tm++;}
    else m = t2/2;
    if(c[m]<c[m+1]) {c[m]+=1; c[m+1] = c[m]-1;}
    while(i<(m+tm)) {c[t2-i-1]=c[i]; ++i;}
}
main()
{
    int t;
    scanf("%d", &t);
    while(t--) {
    gets(c);
    nextpoli();
    printf("%s\n",c);
}
return 0;
}

Wrong Answer , but why anyone explain

  • created

    Nov '13
  • last reply

    Nov '13
  • 1

    reply

  • 441

    views

  • 2

    users

your code does not output correct results for the samples given in the problem statement