Can we solve this question by using char array and not by using vector,map etc.
i have solve it but i got partially correct.
my code
Can we solve this question by using char array and not by using vector,map etc.
i have solve it but i got partially correct.
my code
Hi @goku_11,
I think that your code should have:
char a[10**9][10**9]={'\0'};
This is because n,m according to the constraints are within the range 1 <= n,m <= 10^9
I don’t know if this will result in a TLE or any other error. (don’t know about memory handling)
If it works, please do let me know.
Cheers
Aadarsh…
I guess you are getting partially correct because you are trying to access something out of bound or something related to memory. I’m not sure of it, though, I think if you solve this problem using structures it will be better.
Even I had the same problem at first because of using a 2d array to store data. This fetched me partially correct answer. but then I Improved of some better logic and got AC.
My first solution- (30 points)- using array-CodeChef: Practical coding for everyone
My second solution (70 points+30 points)- Using class(structure)- CodeChef: Practical coding for everyone
Your logic is correct, but using a matrix is not feasible, as matrix as big as [10^9][10^9] will blow up the memory and time limits
Try using an efficient approach and check the editorial
Even I cannot find the editorial for FENCING
pls attach it
a[109][109] memory size you can not be use because their had limit is given for memory 500000 bytes and your array use more space .
you need to create size of a[k][2] .
this problem can be solve using only array use don’t need to use map/vector
simply create a[k][2] size array
link:
https://www.codechef.com/viewsolution/23881868
finally solved it using simple two simple operations
binary search and quick sort
simple implementation using C
Can anyone tell me why this solution gives AC for subtask 2 but not for 1? What I am doing is calculating the sum on the fly by -
This seems like a good solution but since it’s failing, I think the logic is wrong somewhere.
My solution using a single dictionary data structure:
this will result in RE, if defined within main().
As I mentioned above, I didn’t know about memory handling and time limits in C++. I also tried to use a matrix-like structure but resulted in TLE for the 2nd subtask. So, I used a dictionary data structure to store the co-ordinates for easy access (something similar to yours.
My code: CodeChef: Practical coding for everyone
Cheers
Aadarsh…