Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all 39796 articles
Browse latest View live

Confirmance of output to specified format due to newline

$
0
0

Okay I have a question about newlines.Let's say the output format requires you to print a single line of output each line then a newline. What happens in my program is ,after printing of last output case, I end up printing a newline(that's how the program is written). Let me demonstrate how:

Output format specified/required
Case 1: Output line1
Case 2: Output line2
.
.
..
Case n: Output linen
Now, I have printed output as following:
Case 1: Output line1
Case 2: Output line2
.
.
..
Case n: Output linen

Notice the extra newline after Case n: Output linen in my output. Would my output still confirm to the question's specified format?


getting runtime error in C

Code required to execute at most n times

$
0
0

I have come across a question where it is asked in input to have at most n test cases. Something like this is written: "The input will consist of at most #number test cases."
So, basically if I have got a code like this:
int main()
{
//The code to be executed
return 0;
}

What is the code required to execute the code at most#number times?

TEST: Need help with Python code

$
0
0

my code does not pass even single test November challenge 2014 Distinct Characters Subsequence what could be wrong??? (code below)

code deleted

Clarification in SEAPERM2

$
0
0

Hello, in THIS question can any one please say the order of permutation 'q' given in input. I mean does the order or q has to be like q[ 1 ], q[ 2 ], q[ 3 ], ...... or some random order like q[ 4 ],q[ 2 ],q[ 1 ],q[ 3 ],.........

Also can any one please explain this statement " Sereja have made random shuffle of q".I have asked on problem page but no one has replied.

Why Not C?

$
0
0

What there is extra in C++ than C??,I can't I Just Learn C for ZIO & ZCO?? Which is best to get started??

Fast I/O with strings

$
0
0

Hi everyone! I want to know that is there a way like getchar unlocked to input character arrays or strings way more faster? Besides gets, what else can I use to take string or character array as input from stdin faster?

Are Segment Trees needed to query range set problem?

$
0
0

Intuitively it seems that this requires usage of Segment trees. Can anybody comment on whether I am think on the correct line?


Score for the challenge problem not being displayed.

$
0
0

Why is the sore for challenge problem being displayed here? (See the latest solution entry) Does this mean the score is 0?

alt text

coding challenge language

$
0
0

can i submit multiple implementations to see with which language or algorythm performes best?

When will be the results of ACM kharagpur 2014 for onsite declared ??

ICPC Gwalior online round results

$
0
0

Here is the link of online round resuts for ACM ICPC 2015 Gwalior site.

Onsite round will be on Dec 20-21 at ABV-IIITM Gwalior.

ACM ICPC Gwalior Online Contest Ranklist

$
0
0

Gwalior ACM ICPC online contest Ranklist can be found here : link

modular problem

$
0
0

consider a question where a,b,c,d,e,f,g,h,i,j,m=40000 are long long int variable

now i have to calculate ((a * b * c)/(e * f * g ))%m

constrain

a*b>LONG_LONG_MAX

a*c>LONG_LONG_MAX

b*c>LONG_LONG_MAX

e*f>LONG_LONG_MAX

g*f>LONG_LONG_MAX

e*g>LONG_LONG_MAX

but (a * b * c)/(e * f * g )<LONG_LONG_MAX

How to calculate this??

ACM ICPC 2015 Gwalior venue

$
0
0

Where will the regionals of Gwalior-Kanpur site take place? At Kanpur or Kharagpur? And when will the results of the online round (official) be published? Need to make reservations.


Can you describe one of testcase of CHEFSEG

$
0
0

can anyone describe any of the test case of CHEFSEG in NOV14 challenge.

Change of dates of ACM ICPC GWALIOR Regionals

$
0
0

As per the ICPC Gwalior Website , the dates have been shifted to 20-21 December.
Did not expect such change of plans for the major event like ACM ICPC, disturbed the whole schedule :(

What will be the flow of execution??

$
0
0

Memoization

[code]

int memo[n+1]; // we will initialize the elements to -1 ( -1 means, not solved it yet )

int getMinSteps ( int n )

{

if ( n == 1 ) return 0; // base case

if( memo[n] != -1 ) return memo[n]; // we have solved it already :)

int r = 1 + getMinSteps( n - 1 ); // '-1' step . 'r' will contain the optimal answer finally

if( n%2 == 0 ) r = min( r , 1 + getMinSteps( n / 2 ) ) ; // '/2' step

if( n%3 == 0 ) r = min( r , 1 + getMinSteps( n / 3 ) ) ; // '/3' step

memo[n] = r ; // save the result. If you forget this step, then its same as plain recursion.

return r;

}

[/code]

The Next Pallindrome(SIGSEGV error)

$
0
0

This code is running perfectly on my computer and giving the correct answer for all test cases,but don't know why it is giving runtime error(SIGSEGV) while running on the online judges. Tried everything but unable to figure out the reason.

include<stdio.h>

include<string.h>

int main() { int i,j,t,n; char num[10]; scanf("%d",&t); while(t--) { scanf("%s",num); n=strlen(num); num[n-1]=num[n-1]+1; if(n%2==0) { for(i=0,j=n-1;i<(n/2)-1;i++,j--) num[j]=num[i]; if(num[i]<num[j]) { num[i]=num[i]+1; num[j]=num[i]; } else num[j]=num[i]; } else { if(num[n/2]<num[n/2+1]&&num[n/2-1]<num[n/2+1]) num[n/2]=num[n/2]+1;

            for(i=0,j=n-1;i<(n/2);i++,j--)
               num[j]=num[i];

    }
    printf("%s",num);
    printf("\n");
}
return 0;

}

Lowest common ancestor in binary tree

$
0
0

Greetings all !!

Have been trying to figure out a solution to this pretty common problem. There is another instance of this question in codechef forums itself (http://discuss.codechef.com/questions/14645/finding-lowest-common-ancestor-in-binary-tree). Unlike the solution presented there , the question is usually given with two integer values as input rather than two node pointers.There are tons of solutions all over the internet but I have not been able to find a correct solution till now that handles all the following cases.

1) One of the values might not be present in the tree.

2) Duplicate nodes for the same value.

3) the LCA might contain be of the input values themselves.

Any suggestions ?

Edit: One possible solution could be using the concept shown here https://www.youtube.com/watch?v=LFjCr2yDJdc. However the complexity would be O(N^2). Any possible solutions that use recursion ?

Viewing all 39796 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>