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

Separate indication of number of successful submissions with 100pts in long challenge.

$
0
0

I think number of users with full 100 score should be indicated separately. Currently, the no. of successful submissions shown on the challenge page include the partial scorers too. It hides the level of difficulty of the problem. Further, in "All submissions" of a problem, one can only filter problem according to language used or the result (AC/WA/TLE/RTE/CTE). There should be an option for filtering on the basis of score(full/partial) here too. I think code chef should look into this suggestion.


putting classes in different files

Codechef Offline Tester

$
0
0

Hello, I have written a Python Script which can test your program with accepted solution through various inputs.
Here is the description :
Let us say you have solved problem for example TEST, now you can use this script to test your program.Before running this script(I will give instructions on how to run) you need to have a test.py program(which can generate test cases for your program) and binary version of your source code(example : a.out,sample.exe,....).So for now you have your executable,test.py with you.Now you can start executing this script.Run this script using "python Check.py"(with out quotes).It will prompt for :
1) Problem Code (TEST in this case)
2) Path to your executable(a.out,sample.exe,...)
3) Path to your test.py
4) Time Limit
5) Number of test cases(with which you need to test your program)
After you have given this information, this script will start extracting accepted c++ code for that particular problem, generate intputs with the help of test.py,outputs with the help of extracted solution, test your program with those outputs.Then prints the Verdict(Accepted,WA,TLE,RTE) for each test case,including execution time.At the end it will print stats, and ask for queries
Queries are :
-- Quit or q : To quit
-- Manual : Give Manual input(You need to type EOF in a new line after end of input)
-- Help : Print Query types.
-- ACC : Print accepted test case indexes
-- WA : Print wrong answer case indexes
-- TLE : Print TLE case indexes
-- RTE : Print RTE case indexes
-- < Number > : Print the stats(Input,Output,Answer,execution time,verdict) of respective testcase
For now I did not take care of some bugs, error handling,..., for bug reports,suggestions,problem with understanding, ..... you can comment here or mail to achaitanyasai@gmail.com
I have tested this script in LINUX, It works perfectly fine, I am not sure whether it will work in windows or not ....

Best,
Chaitanya.

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??

exection time

$
0
0

why same code take different execution time when we run it again and again ?

Can I get advise on implementing live video chatting and live voice calling between two clients in sever client socket programming using Java?

$
0
0

I want to implement live video chatting and live voice calling between two clients in sever client socket programming using Java. So anyone have some clue then please share.

Different Compilers/Interpreters/Tools

$
0
0

Here is a list of compilers in C++ for windows which I know of. Please add your favourite programming tools in this list.

1> Microsoft Visual C++ (express edition) (a very good compiler)

2> Vim

3> Emacs

4> Rhide

5> gcc + Code::Blocks (most accepted combo but seems outdated)

6> gcc + Dev C++

7>TC/gcc + Notepad++

8> www.ideone.com (you can access it from mobile devices including old fashioned java mobiles)(do more than C++)

9> gcc + Netbeans ide

Tools:

1> Profilers (which tell you about performance/memory usage)

2> Breakpoints (which are marked lines in c++ which allow you to watch execution step by step. I like this feature in Microsoft VC++)

size of array

$
0
0

why we take big size of array than the size required in question. for example if in question maximum size of string will be 10000. then we take char s[10005] or char s[10001] etc.


cant solve challenges

$
0
0

I am not able to solve even a single question in any of the codechef challenges.The main problem is storage size. My programs doesnt give output for large values like 1000000,etc I am new to programming and I dont know how to start.So please anyone help me....

A new website I've came across

$
0
0

Hello @all,

As you all know, I struggle with Maths a bit and sometimes after contests I tend to be "keen on" or very interested in learning a new specific data structure!!

I have found this website thanks to Codechef for Schools (along with some extra digging) which is called:

Jan's LightOJ

which, as you can see from the link has ALL problems organized under specific categories like, DP, Trees, etc.

It's a bit like tags but at same time is also more visual and it actually allows one to see how many problems from each category you have solved!

So, I thought that maybe some beginners would find this website helpful and I decided to share it here :D

Best regards,

Bruno

C++ compiler

$
0
0

Which is the best C++ compiler ? How can we download and install GCC compiler and use it with VIM and EMACS editor to compile and run our code ? Thanks.

ZCO 2015 Cutoffs

$
0
0

Post your ZCO 2015 result here! Hopefully we can estimate the cutoff.

What is wrong in my code for Double String ?

$
0
0

This is the code I had submitted :-

#include <stdio.h>
int main ()
{   int t,j;
    scanf ("%d", &t);

    for (j=1;j<=t;j++)
    {   int n;
        scanf ("%d",&n);
        if (n%2==0)
        printf ("%d",n);

        else
        printf ("%d",n-1);
    }
    return 0;
}

Can anyone explain why it is wrong ?

ZCO 2015 problems

$
0
0

How was it?? I couldn't do even one problem out of two (afternoon session)

Promblems are Q1 and Q2

FARASA - Editorial

$
0
0

PROBLEM LINK

Practice
Contest

DIFFICULTY

HARD

PREREQUISITES

Fast Fourier Transform

PROBLEM

You are given an array of N positive integers. There are N+1C2 sub-arrays of this array. Find the number of unique sums possible among all the possible sub-arrays.

QUICK EXPLANATION

Although the problem statement isn't as direct as the problem description used above, it is very easy to come to the conclusion that this is indeed what the problem to be solved is.

The limits to the problem were given rather innovatively as

1 ≤ N * S ≤ 4 * 1010

Where S is the sum of all the numbers.

Considering all the numbers are positive, the real limit on N is hence

1 ≤ N ≤ 200,000

We note that S can vary greatly as N varies and hence we cannot solve this problem for all values of N under the same algorithm. We break our solution into 3 different methods meant to solve the problem for different values of N.

EXPLANATION

1 ≤ N ≤ 2,000

For this limit of N

  • The number of sub-arrays to be considered are at most 2,001,000
  • The value of the sums can be at most 40,000,000,000 (for N = 1)

We can generate all the sums and eliminate the duplicates. We cannot eliminate them using a lookup table because of the possibly large value for the sums.

The complexity of this procedure would be O(N2 log N). The complexity is driven by the procedure to sort before we eliminate the duplicates.

sums = []

for i = 1 to N
    value = 0
    for j = i to N
        value += A[j]
        sums.push(value)

sort(sums)
eliminate-duplicates(sums)

2,000 < N ≤ 20,000

For this limit of N

  • The number of sub-arrays to be considered are at most 200,010,000
  • The value of the sums can be at most 20,000,000 (for N = 2000)

We can still generate all the sums and eliminate the duplicates. Note that sorting to eliminate the duplicates can be quite expensive since we are potentially considering over hundred million values. Fortunately, the value of sums has come down within the range to maintain a lookup table!

sums[] = { 0 }

for i = 1 to N
    value = 0
    for j = i to N
        value += A[j]
        sums[value] = 1

answer = 0
for i = 1 to MAX_SUM
    answer += sums[i]

The lookup table helped us avoid the cost of the sorting step to eliminate duplicates. We still relied upon our ability to iterate over every possible sub-array's sum. The complexity of this procedure is O(N2 + S).

20,000 < N ≤ 200,000

For this value of N

  • The number of sub-arrays to be considered are at most 20,000,100,000
  • The value of the sums can be at most 2,000,000 (for N = 20000)

We can no longer iterate over each sub-array because there could be too many of them. But we note that the value of the maximum possible sum is now very manageable. We can use this to our advantage by trying to base our approach completely over the possible values for sums.

Let us consider an array of sums of prefixes

S[i] = sum( A[x] : 1 ≤ x ≤ i )

We wish to find all the possible values generated by

S[j] - S[i]

for each 1 ≤ j ≤ N AND 1 ≤ i < j. This convolution can be generated by the product of the following two polynomials

X = x0 + xS[1] + xS[2] + ... xS[N]
Y = x0 + x-S[1] + x-S[2] + ... x-S[N]

The number of terms in the product of X and Y, which have non-zero coefficient and positive power, is the answer we are looking for. To only deal with positive powers in our problem, we can multiply Y with xS[N] and check the coefficients of all the terms xS[N]+1 and above in th resultant polynomial.

The fastest way to multiply two polynomials is using FFT. We can multiply the two polynomials as follows.

fX = FFT(X)
fY = FFT(Y)

fT = fX . fY (dot product)

T = iFFT(fT)

Thus, we can solve this case in O(N + S log S) time.

SETTER'S SOLUTION

Can be found here.

TESTER'S SOLUTION

Can be found here.


Split an array into k subarrays of sum s

$
0
0

I have an array of length N, let's say something like:

4 6 4 6 4 6

I need to split this array into P subarrays (in this example, P=3 would be reasonable), such that the sum of the elements in each subarray is s(lets take s=10) : for this ans is {4,6} {4,6} {4,6}

but for this array

3 6 3 6 6 6

there is not any solution. So guys help me out please....

getting 3 % 15 as 3 in the below program.

Multiplicative Inverse

$
0
0

How to proceed for calculating the multiplicative inverse of number when M is not prime.
Eg. if M= 7 the MMI of 4 is 2 as ( 4 * 2 ) %7 ==1,
if M=11, the MMI of 7 is 8 as ( 7 * 8 )%11 ==1,
if M=13, the MMI of 7 is 2 as ( 7 * 2 ) % 13==1.
When M and the other number are co-prime,only then it can be calculated as above.
Is there a way to do it when they are not co-prime?
How to solve such problems?
Thanks!

PRIME1 TLE on Codechef but AC on SPOJ

$
0
0

Hello! I have just submitted the solution to the problem PRIME1 on SPOJ with AC. But on codechef when I submit it gives TLE. Here is the link. http://ideone.com/ZGIRgq. Please have a llok and help me.

getting wrong answer in The Next Palindrome. Please provide test cases for wrong answer

Viewing all 39796 articles
Browse latest View live


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