what are sub tasks?how to accomplish them?

many problems on codechef have constraints,and sub tasks. what are they? and how they should be dealt with?
i mean if the provide the range,then m i supposed to use if condition for range of input?

Hi @ansh1star033! Constraints are just given to provide you an idea as of how long or exactly what data type should you use. Most of the times here int won’t work because according to constraints, some variables might take a value exceeding the range of int, so you use long or long long there. e.g. Given constraints on a variable n: n<=1000000000, so you declare n as:

long long n;

If you don’t do this, for test cases with input value higher than range of integers, your program might throw some garbage value.

Sub task means different levels of input on which you will be judged. It means that unlike other questions where you need to pass all the test cases to get an AC, here even if you pass one sub task you will get AC but not full marks. Distribution of marks may differ from task to task.

1 Like

So,sub tasks just tells about the marks distribution,it has got nothing to do with the code,i mean write different code for different subtasks,or manage it somehow.
Are these given so that we get to know the judging criteria of that problem only?

hi, what does this mean??


1 ≤ T ≤ 10

1 ≤ N ≤ 105

Si = {‘R’,‘G’,‘B’}

Subtask 1 (40 points) : 1 ≤ N ≤ 10
Subtask 2 (60 points) : original constraints

@noobfh : The constraints will tell you the minimum and maximum value of variables used in input. In the case described above, T will not exceed 10 in any test case and N will not exceed 10^5 in any test case and Si will be any of R,G or B.

Now for the subtask 1, it is given that all the test cases will contain value of N not exceeding 10.
and in subtask 2, N will be same as of original constrains i.e. not exceeding 10^5. So, based on the constraints you can estimate the running time of your program by calculating its time complexity and you can know the data type to be used for the variables.

@ansh1star033: You don’t have to write different codes for different sub tasks, just make sure that you have taken data type which wont overflow with given constraints. Subtasks do tell marks distribution and they are useful as you will get partial score if any subtask passed which better than getting no score.

terimakasih atas informasinya gan sukses selalu informasinya sangat sangat bagus
Obat Kram Perut Tradisional

In essence, you need to accomplish all sub-tasks to get full marks. But even if you don’t accomplish all sub-tasks, you won’t get a WA if you have accomplished at least one sub-task.