Unable to complete the subtasks.

I’m a total beginner to competitive programming and the sub-tasks are way over my head. So it would be appreciated if any body could take some time out and help me in understanding the sub tasks in the most easiest way possible.

Example : CATSDOGS Problem - CodeChef

Subtasks -

  1. Subtask #1 (20 points)

1 ≤ T ≤ 10^4

0 ≤ C, D ≤ 10^2
2. Subtask #2 (30 points)

1 ≤ T ≤ 10^5

0 ≤ C, D ≤ 10^3
3. Subtask #3 (50 points)

Original constraints

4 Likes

You are missing out certain cases.

Give a try finding possible cases/conditions when count is correct or incorrect

In case you still get WA, here’s the link of my solution.

As you want an explanation about sub-tasks , I am not going into the logic or solution to the problem itself , and writing only about how the sub-tasks and points system works.

In general , sub-tasks are nothing but sets of constraints on the minimum/maximum values of the variables defined in the problem.

In simple language , for the given problem , you will get 20 points if your program can show correct answers within the time limit when the value of T is between 1 and 10^4 , and C and D are between 0 and 100 . You will get 20+30 points if your program can handle both this and larger values of T , C and D as mentioned in subtask 2, and will get 20+30+50=100 points if it can show correct results for all the three sets of constraints

How can a code pass one set of sub-tasks and fail others ?

As the constraints increase , your code might show wrong answer due to some faulty logic , or some variable overflow. The algorithm might not be optimized enough so it might exceed the time limit for larger constraints. Basically what it means is that only a correct answer to the problem is not enough for 100 points , your answer has to be scalable and optimized in order to get 100 points.

How to make your programs scalable and optimized ?

That is the whole point of competitive programming. You will have to read up extensively on data structures and algorithms , understand what sort of logic to use where , etc. All of this will come from practice and study.

I hope I was of help , if anything is unclear comment and I will try to help you out as good as I can :slight_smile:

19 Likes

@hari16999

Some cases where your code outputs WA.

2

0 1 4

1 0 4

Output:

no

no