Блог пользователя KaryGauss03

Автор KaryGauss03, история, 4 года назад, По-английски

Hello there. I am writing this blog to share with you my experience on being Expert in 5 months and to help people who want to imporve their skills in Competitive Programming and even for those who want to start in this field.

And now, let’s start with some important tips from my point of view :

Set your own goals : The good spirit is to fix goals to achieve, for me my goal was to be the first Tunisian who achieve ICPC. And before ICPC, I must be qualified to ACPC (Africa & Arab Collegiate Programming Championship). So I worked hard in the first 4 months, and I was qualified to ACPC by having the 3rd Place in TCPC (Tunisian Collegiate Programming Contest). And to be honnest, it was unexpected for me. But it happens.

You should like what you are doing : If you like a subject, you would be good at it.

while(true) { practice_and_never_give_up () ; }

Select the problems according to the topics you are targeting : This will be very helpful for you during the practice.

Learn new data structures and algorithms : learning new data structures and algorithms (like DFS, BFS, Dijkstra ect ..) will help you to improve your skills. Also, some maths skills can help you to solve some problems faster (Number theory, combinatorics, ect …)

Avoid easy problems : Beginners' problems are a waste of time for who have mastered the basics of competitive programming.

Focus on your performance during contests : don’t look for the scoreboard during the contest. Foncus on your performance and try to solve the problems efficiently. You will sometimes encounter a few defeats and even have a low rating, never mind, it’s normal, try to know your weaknesses and fix them.

Check editorials if you failed : Sometimes you will spend hours trying to find a solution for your problem; in this case you read some lines from the editorial and keep trying again in the problem until you solve it. Even if you can’t solve it, don’t worry, you can read the solution and understand the trick, then re-solve the problem by yourself again.

I hope those tips help you. I want to thank Mtaylor and ziedom for inspiring me and helping me during my trainings.

NOTHING IS IMPOSSIBLE . Start Learning, Start Coding and Start Solving Problems

  • Проголосовать: нравится
  • +63
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Congrats!

»
4 года назад, # |
  Проголосовать: нравится -16 Проголосовать: не нравится

Very Informative. I'll be an expert in the next round with your approach.

»
4 года назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится
»
4 года назад, # |
  Проголосовать: нравится -27 Проголосовать: не нравится

can you kindly tell what all data structures and algorithms like in number theory there are so many algos so among those which all you learnt you learnt along with practice? did you solved cses problem set?

PS: Congrats for becoming expert, wishing you more success. Sorry for my bad English too :-)

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +11 Проголосовать: не нравится

    Why people are downvoting my comment and Question

    • »
      »
      »
      4 года назад, # ^ |
      Rev. 2   Проголосовать: нравится +14 Проголосовать: не нравится

      Sadly because your English is really too bad. :(

      I guess you wanna express that what algorithms he has learnt, like DFS or blahblahblah.

      For basics:

      • Recursion (maybe a little more Divide and Conquer)

      • Greedy

      • Prefix Sum

      • Binary Searching

      • Sortings (just being able to use std::sort in C++ and reload the comparing function is enough)

      Searching:

      • DFS

      • BFS

      Dynamic Programming:

      • Knapsack

      • Interval

      • DP On Trees/DAGs

      • Bitmasks (a little maybe)

      • A LOT OF Different DP

      Strings:

      • Hashing is enough

      Maths:

      • Bitmasks (a little)

      • Binary Exponentiation

      • Primes (a little)

      Data Structures:

      • Stack

      • Queue

      • List

      • Union-Find

      • Heap

      • Monotonic Queue (a little)

      • Binary Indexed Tree

      • Segment Tree (only the easiest one)

      • Able to use std::set and std::map in C++

      Graphs:

      • DFS

      • BFS

      • Trees

      • DAG

      • Minimum Spanning Tree

      • Sortest paths (I strongly recommend Dijkstra, that's enough.)

      Don't get scared. Just learning the basics of the algorithms and try to improve in contests. The skill to judge what algorithms to use on a problem is also important. You can try to pick problems with difficulties as high as or a bit higher (like 300 points) than your rating.

      UPD: Learning how to analyze your solutions complexity is VERY important.

»
4 года назад, # |
  Проголосовать: нравится +35 Проголосовать: не нравится

If you like a subject, you would be good at it.

There are lots of people who actually like CP but are hardstuck in Div. 3.

Learn new data structures and algorithms

Apart from the primitive ones, there are barely any algorithms that you will need to get to blue (or even yellow these days, for that matter).

Focus on your performance during contests

If you focus on your performance, you will get distracted by it regardless of how well you're doing. Instead, focus on the problems.

don’t look for the scoreboard during the contest.

Sometimes a problem that is supposed to be hard is easy, the scoreboard helps you with finding those. In the contest I ranked up to IM, I would have lost rating if I hadn't checked the scoreboard because I wouldn't have known that that particular div1D was easy.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    1) Yes, there are people who love CP and find it hard, but they won't give up, they will keep trying and trying. This is why this is an important point. 2) You can't focus on your performance without focusing on the problems. 3) When I said don't look at the scoreboard, I mean don't be stressful about the ranking, you can check which issues are easy or not without looking for the ranking. Just check the number of ppl who solve each problem. The main idea is to look at the CP as a skill to improve, for your job interview or I don't know, and not as a rating. Thank you for your remarks, can you please share your experience with us ?

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +13 Проголосовать: не нравится

      Yes, there are people who love CP and find it hard, but they won't give up, they will keep trying and trying.

      Not giving up doesn't mean that you are good, neither does it mean that you are improving. Don't you think it would be disheartening and insulting to hear "If you like it, you will be good at it" if you love CP and you have been trying for months if not years to improve but to no avail?

      You can't focus on your performance without focusing on the problems.

      How did you get that idea? There are lots of people that just start complaining about how they're going to lose rating on Discord after getting a little stuck on an early problem, or people that start panicking and start calculating which problems they need to solve in order to not lose rating. I've seen them myself, do you think I'm making this up?

      When I said don't look at the scoreboard, I mean don't be stressful about the ranking

      If so, I agree.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +19 Проголосовать: не нравится

    there are barely any algorithms that you will need to get to blue (or even yellow these days, for that matter).

    (or even red these days, for that matter). But the OP was talking about very basic algorithms like DFS, BFS etc that are not well known to newbies, so it'll be good if they learn those.

    Sometimes a problem that is supposed to be hard is easy, the scoreboard helps you with finding those.

    That's true, I would also like to add that you can sometimes guess a lot of things about a certain problem's solution just by looking at the standings. (For example, "a lot of people solved this problem in 5~10 minutes, there is probably a hidden observation which will make this solution a 2 liner")

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      Idk why are u and chromodynam1c is forgetting to tell that without seeing the leader board one can see the dashboard if he wants to see the number of submissions of each problem :(

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Doesn't that have the same effect as looking at the leaderboard?

        • »
          »
          »
          »
          »
          4 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          No, not at all... On leader board one can see his rank and his friends' rank which may give tension to him like his friends did a question earlier than him... While on dashboard u can only see the question and number of AC solutions( which will help him to recognize if a question that is supposed to be hard is easy).

          • »
            »
            »
            »
            »
            »
            4 года назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            Wouldn't seeing that thousands of people solved a problem that you're completely stuck on also give anxiety? Why is seeing your friends any different? I guess for some people seeing the friends leaderboard might be worse, but I still don't think that looking at the dashboard won't make you anxious if you're bothered by the friends leaderboard.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

      (or even IGM these days, for that matter, not talking about me but other people)

»
4 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Wow, just find that my first contest is on Jan/11/2019 and I became expert on Jun/11/2019, which is exactly 5 months :)

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

I just find it took me 2 months to become expert with 2nd contest on 26 march (during 1st contest, I didn't even know how to take input XD) and becoming expert on 26 may.

»
4 года назад, # |
  Проголосовать: нравится -20 Проголосовать: не нравится

Hi guys I am doing competitive coding for some time now and got quite experience. I want to know while solving binary search problems how you guys get to know whether it would work or not in one go. for me its always trial and error and I always end up in an infinite loop. Is there some fix method and how to know if some method would work or not

int solve(vector<int>&A, int x, int y,int left, int right){
     while(left<right){ // some times here we get (left<=right)
         
        int mid=left+(right-left)/2;
        // watch(mid);
        if(some_condition(){
            right=mid-1; // some people do right= mid here
            
        }
        else{
            left=mid+1;  //some people do left= mid here
        }
        
    }
    return left;
}
  • »
    »
    4 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    A good technique:

    if you are looking for 1st position satisfying some condition do this:

    mid=(left+right)/2;

    if(some_condition()) left=mid+1;

    else right=mid;

    if you are looking for last position satisfying some condition do this:

    mid=(left+right+1)/2;

    if(some_condition()) left=mid;

    else right=mid-1;

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      what about left< right or left <= right. Also both of these conditions are failing in a problem (painter's partition)

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Can you link the problem?

        • »
          »
          »
          »
          »
          4 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          https://www.interviewbit.com/problems/painters-partition-problem/

          #define watch(x) cout << (#x) << " is " << (x) << "\n"
          #define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
          bool isPossible(vector<int>&A, int x, int y, int k){
             int n=A.size();
             int temp=0;
             for(int i=0;i<n;i++){
                 
                 if(A[i]+temp>k){
                     x--;
                     temp=0;
                     i--;
                     if(x<0){return false;}
                 }
                 else{
                     temp+=A[i];
                 }
             }
             if(temp!=0){x--;}
             if(x<0){return false;}
             return true;
          }
          int solve(vector<int>&A, int x, int y,int left, int right){
               while(left<right){
                   
                  int mid=left+(right-left)/2;
                  // watch(mid);
                  if(isPossible(A, x, y, mid)){
                      right=mid;
                      
                  }
                  else{
                      left=mid+1;
                  }
                  
              }
              return left;
          }
          
          int Solution::paint(int A, int B, vector<int> &C) {
              int sum=0;
              int mod=100000;
              // sort(C.begin(), C.end());
              for(auto it:C){
                  sum+=it;
              }
          
              return (solve(C, A, B, C.back(), sum)%mod*B%mod)%mod;
          }
          
          

          this is my code

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

It's really an incentive for me, thanks a lot. Also, Congratulations on becoming expert!

»
4 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Congratulates!

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Congrats!

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Good Job !

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Awesome achievement! Keep it up <3