CuteCoder07's blog

By CuteCoder07, history, 8 years ago, In English

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.

  • Vote: I like it
  • -1
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
  Vote: I like it +28 Vote: I do not like it

just solve more and more problems.

»
8 years ago, # |
  Vote: I like it +3 Vote: I do not like it

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.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I do agree with this. But keep in mind to consider tricky cases if you choose not to read the whole question

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think this is a wrong way.Many important information will be missed.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Ugh I just realized this blog is 3 years old...... why the fuck do people bump these :/

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    8 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Do you know where to learn graph? I'm looking for website with simple implement about algorithms like graph, dp, etc.

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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://codeforces.me/blog/pllk just released a free book on competitive programming which is really good.

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

»
8 years ago, # |
Rev. 2   Vote: I like it +10 Vote: I do not like it

Some tricks:

  1. test crawler : parse sample test cases from web page. No copy'n'paste any more.

  2. test script : diff your output with expected output

  3. turn on more compiler warnings

  4. useful shorthands in your template

  5. a standard code library: it can be included like standard library without copy'n'pate.

  6. start coding only after you have clear idea. Otherwise you will waste time to change your code frequently and debug.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    How can you include personal code library without copy paste?

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      combine all included files in my library by a script. also copy it to clipboard, or submit it directly.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      8 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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 :)

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

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

»
8 years ago, # |
  Vote: I like it +5 Vote: I do not like it

also never ever use pow function in c ++

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    can you explain why?

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      In most languages, powreturns a double. This can lead to silly precision issues where pow(10,2) = 99.