Hi, Sorry if this is newbie question, but I solved some easiest problem in codeforces, and i wonder, how can i improve my speed to solve these problem? i don't know what to do to improve my speed, should i learn some algorithms to increase my speed? Thanks.
just solve more and more problems.
Learn to find the fact without read the whole problem statement,
For example, you can read from the input part, and find what the meaning of
N
,M
,X
, etc. Once you understand the problem and got the solution, code your solution as fast as you can.N.B. I think it'll only work for problem A, or sometimes problem B. But it depends on your strength.
I do agree with this. But keep in mind to consider tricky cases if you choose not to read the whole question
I think this is a wrong way.Many important information will be missed.
I agree this is totally not the way specially if you're new. You'll end up missing a lot of info and just getting more stressful and anxious. What you need to improve is coding skills and not reading skills..... Coding can be improved by solving more and more problems.
Get a stopwatch and record how long do you take to solve a problem A from the first read till AC and aim for getting it in less then 10 minutes. If you manage to do it, that's already great and it's time to move on to Div2 B and C.
Ugh I just realized this blog is 3 years old...... why the fuck do people bump these :/
LMAO its okay i'll upvote you
If you are trying to solve div 2 A problems the algorithms provided in and STL containers should be sufficient. However once you start solving div 2 B or div 1 A you will need some additional algorithms for working with graphs certain problems as well as others for other situations.
Do you know where to learn graph? I'm looking for website with simple implement about algorithms like graph, dp, etc.
I am not sure about websites this is the standard books on algorithms https://en.wikipedia.org/wiki/Introduction_to_Algorithms I learnt most of my graph theory and dp stuff from it. Also this guy http://mirror.codeforces.com/blog/pllk just released a free book on competitive programming which is really good.
If you are lazy you can find ready-to-use implementations (java only) from algs4.cs.princeton.edu (Algorithms by Sedgewick and Wayne). They are much faster than built-in java things, for example PriorityQueue. There are many useful things like graphs, MST, network flow, etc. that are also implemented.
If it doesn't exist there, just translate the pseudocode from wikipedia.
They are much faster than built-in java things
Just curious, how did you know? Is there any bench test done or is it base on experience?
Well, it seems like they have a lot less corner case handling and etc. I haven't really looked at the code that much. But here is a case where the built in priority queue fails:
http://mirror.codeforces.com/blog/entry/47908
But i'm not use java, is that possible to implement it to c++?
Try this: https://github.com/indy256/codelibrary/tree/master/cpp
or you can just translate it yourself, it is not hard.
Some tricks:
test crawler : parse sample test cases from web page. No copy'n'paste any more.
test script : diff your output with expected output
turn on more compiler warnings
useful shorthands in your template
a standard code library: it can be included like standard library without copy'n'pate.
start coding only after you have clear idea. Otherwise you will waste time to change your code frequently and debug.
How can you include personal code library without copy paste?
combine all included files in my library by a script. also copy it to clipboard, or submit it directly.
Advises 3 and 6 are very reasonable, but I don't think any of those will increase your skills in the long run. If you want to be better, just solve many problems.
Sure. These are just some competitive programming tricks.
But when I stop wasting time in these useless labour (copy test cases / diff by eye / debug / write the same code again and again), I can solve more problems :)
I am now able to solve problems up to div2 D level 1800-1900 rated but i m very slow can you plz suggest what should i do currently i used to solve Div2 D daily like 10-12 problem daily of codeforces should i continue this or should i jump to other websites like atcoder,topcoder,codechef i m familiar with codechef, i found topcoder's environment too complicated for my stupid ass, and i didn't tried atcoder yet!!! THANX IN ADVANCED LIKE IF YOU EVER REPLY TO MY COMMENT!!1 THANK YOU!!! Errichto can you also plz make a video for someone like me i found ur videos quite good!!!
also never ever use pow function in c ++
can you explain why?
In most languages,
pow
returns a double. This can lead to silly precision issues wherepow(10,2) = 99
.