ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1685. Orthography

please check my code WA 3
Posted by Raman Gupta 3 Dec 2012 12:42
#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*/
Re: please check my code WA 3
Posted by staticor 18 Jul 2013 12:26
input output
Re: please check my code WA 3
Posted by Xel 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:])