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

Автор Kognition, история, 5 лет назад, По-английски

If you had a smart friend who liked puzzles, and you could choose one problem that you thought was accessible and interesting enough to get them curious about competitive programming, what problem would you choose?

Edit: To be clear, I’m curious about specific problems, not just general topics.

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

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

Fibonacci with Matrix Expo did it for me. Knapsack would have probably worked too.

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

    I agree that Fibonacci with Matrix Expo is really cool when you first see it. That said, if just presented with the problem, i.e. (given this recurrence, find the $$$n$$$'th term), one could get a closed form with generating functions and might not immediately see why fast matrix exponentiation is, in fact, really cool and more generally useful.

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

geometry problems :P

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

For me, I think the most important and interest thing is that you should use computer to calculate complex processes to get final result. So give problem which is hard to describe exact answer directly, then he or she will have interest in competitive programming.

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

I agree with a previous commenter; Fibonacci with Matrix Expo similarly got me hooked.

Combi in general was something I found interesting from Math competitions, but with a computer, so many more avenues are opened and much more interesting problems can be asked.

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

I will give Number Theory problem.

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

When I started competitive programming I was absolutely thrilled by problem "Garden" from IOI 2005. You start by the trivial $$$O(N^{10})$$$, come up with smart ideas to make it $$$O(N^5)$$$, and optimize to $$$O(N^4)$$$ and finally $$$O(N^3)$$$ by discovering new optimizations that have general implications.

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

32C - Flea

Was also the problem that got me into CP

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

i really liked this problem 1092D1 - Great Vova Wall (Version 1)

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

    Ah yes, that's a nice one. I first heard the problem presented where you had to prove (noninductively) that all the ants would fall off the log.

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

any love for Your Ride Is Here?

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

This is an interesting question but also a strange one. Do you want a reaction like "you can solve this? This is incredible" or for a person to understand and maybe be able to solve the problem? If second — do this person know about time complexity? If yes, this is incredible, why would anyone know about time complexity outside of CP? If no, I don't believe that you can show relation to programming, it should be pure mathematical problem, which is not what you want, I suppose.

I guess there is some middle ground like being able to grasp the problem statement and think about the problem a little bit, but hardly coming up with a solution.

Anyway, my recommendations (probably too hard for someone not in CP, especially the first one, I mean tourist and Petr didn't solve that one, though my classmate did): TCO16 Semifinal2 Easy, TCO17 2C Easy. Wow, two problems from TopCoder from a person who don't like TopCoder. That's embarrassing.

Also kinda theoretical problem if they know about complexity: Given an array of length $$$n$$$, you can take a segment and reverse it. The cost of this operation is length of reversed segment. Come up with an algorithm that sorts the array spending $$$o(n^{2})$$$ (faster than bubble sort. I don't know optimal complexity, but I do have pretty good one). To all: feel free to write your algorithms in comments to this one (using spoilers, of course).

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

    People ask you for question, you give them history books !

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

      I still recommend you to stick to "just Petr" comments, because otherwise you always write something stupid. On the other hand, Petr is not stupid.

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится +34 Проголосовать: не нравится
    Complexity
    Solution
    tl;dr

    Nice problem!

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

    So, my intended audience would probably have some basic knowledge about time complexity (perhaps they wouldn't be able to do certain things like prove Manacher's is $$$O(n)$$$ or something, but they would probably be able to reason about some pretty simple data structure complexities). The middle ground you presented sounds accurate to what I was looking for. That said, you can interpret the question in whatever way you are comfortable with answering; I enjoyed the problems you shared.

    Also, time complexity is really not specific to CP; most algorithm and discrete math classes in the US teach about time complexity, and to be honest I would be astounded if it was not taught in Computer Science classes in Russia, which has a much better STEM education system than the US.

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

Interactive problems would be a good choice. They rarely require knowledge of algorithms.

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

    I agree; in fact, when I wrote the question, I was thinking of problem D from this year's Code Jam qualification.

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

      Really? It's not interesting, there are much better interactive problems.

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

        That's unfortunate that you didn't think it was interesting; I suppose it was probably too easy for you. It was nontrivial for me and the solution was pretty and simple enough that I could present it to my friends without much background, and still see the "Oh!" looks on their faces afterward.

        Perhaps you'd like to share some of your favorite interactive problems? Although not interactive, I enjoyed your segment reversal problem from above.

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

baseball elimination problem :D

How you solve it using Graph and Max flow out of nothing really amazed me the first time I read about it.

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

This problem from NCPC is rather interesting (realistic): you have $$$N$$$ teams, each with $$$M$$$ people, and you want to run a tournament where each pair of contestants from different teams plays exactly one game against each other, with the minimum number of rounds — $$$M(N-1)+1$$$ is enough. In one round, each player can play one game. The goal is to make a tournament table — who should play against whom in each round.

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

    I have no clue why this was downvoted so much. I think this is quite a cool problem.

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

      Haters gonna hate. Don't look for any sense in CF votes.

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

      I think this problem is way too hard, hard enough thst copy-pasting Vizing’s coloring algo is a most sensible choice. I can imagine someone liking this problem but it’s not in my taste.

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

        Ah, I see. I suppose my opinion was positively influenced by the fact that I didn’t know the solution.

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

        I didn't mean that it's a good problem to give someone to solve. It's something people without experience in competitive programming can connect with and that can serve as an entry to the topic. From real-life experience with such people, I'm pretty sure a "smart friend who likes puzzles" will find the sieve of Eratosthenes way too hard, even though it's trivial for us.

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

I like this problem a lot — Trapping Rain Water 3D , but the preferrence depends a lot on personal skill, interests, problem solving history, etc.

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