ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1685. Orthography

Raman Gupta please check my code WA 3 [3] // Problem 1685. Orthography 3 Dec 2012 12:42
#pragma comment(linker, "/STACK:16777216")
#include <stdio.h>
#include <string.h>
#define size 20010
char str[size];
char arr[size];
int i=0;
 void recurse(int low,int high){
      int mid;
     if(low>high)
         return;
     mid = (low+high)/2;
     arr[mid] = str[i++];
     recurse(low,mid-1);
     recurse(mid+1,high);
 }

 int main(){
    scanf(" %[^\n]s",str);
    recurse(0,strlen(str)-1);
    printf("%s\n",arr);
 return 0;
 }

/*I simply used recursion and its working for all the test I know presently.Please tell me what is the problem in the code*/
staticor Re: please check my code WA 3 // Problem 1685. Orthography 18 Jul 2013 12:26
input output
Xel Re: please check my code WA 3 [1] // Problem 1685. Orthography 28 May 2014 19:25
the same

def solve(str):
    l = len(str)
    if l<=2:
        return str
    mid = (1+l)//2
    return solve(str[1:mid]) + str[0] + solve(str[mid:])

print solve(sys.stdin.readline().strip())

it's working for all the test I know, but get WA3 here
ura Re: please check my code WA 3 // Problem 1685. Orthography 3 Feb 2019 13:55
Xel,отличное решение!
Только вместо функции strip() нужна функция strip('\n'),
иначе удаляются все концевые пробелы и этим самым
нарушаются входные данные.

Edited by author 03.02.2019 13:56