Hello Codeforces community, A newbie here.My name is Sayan Chaudhuri and I am from India. Although as you can see my rating is low, I particularly face high difficulty while solving problems based on games. Like problems of DIv 3C or Div2B which often are problems based on games, I find it extremely troubling to solve them. I just get bamboozled when I find the term "optimally" as it does not occur to me, what an optimal move could be...So, how do you guys approach these problems on games.. If anyone can give me some intution or any sort of other help that may help me to overcome this difficulty. round 668 div2 problem B Sequential Nim- this problem is an example. I am not just able to understand how to solve it.... Thanking you in advance...
Prerequisite:
Combinatorics
Dynamic Programming
Resources:
https://codeforces.me/blog/entry/66040
There is no generalization to such problems. These can be based on constructive thinking, some simple if-else criteria, Nim's game, combinatorics, greedy or dp. Again, these are only a few possibilities that I have came across, there is NO generalization.
Thanks for your feedback. The problems that I have encountered so far normally involve simple if else ....let's see how can I improve further on this..
When I have no idea what the optimal play is I try to play the game on paper for both the players and choose what would be optimal for both sides, and after that it is easier to see the optimal play for both players
First of all, I have no idea why are you getting down vote.
I will explain how I approach Game theory problems with two examples:
Consider problem 1404B - Tree Tag (which I was able to solve):
Thinking about: How would I win the game if I was Alice?
This leads to (Let the length of the path between us be $$$dist$$$):
Now what if I am Bob? How would I win?
And the problem is solved. Note that the process of solving the problem has two parts (In two player games), and in each part, you should come up with some if statements. Start from easy conditions, write them on paper, and go on. Remember that most of the game problems are solved using easy terms. Referring to 1375F - Integer Game. Many scared from "Print First or Second" part. But the solution was to win in 2-3 steps. The main reason for not solving the task during the contest is having fear.
Now consider 1404D - Game of Pairs (which I wasn't able to solve):
Yeah I didn't solve it during the contest, but I have something to say.
Thinking about: How should I win as First?
Thinking about: How should I win as Second?
So what to do in these situations? Leaving the contest is the option for many people, but for me, it was: try to solve it for small $$$n$$$. This way I guessed that the solution is based on the parity of $$$n$$$. It should be a nice attempt when you have no idea, and helps you to guess the condition in problems that the condition is short, which was the case for this problem.
So what else? Now I may assume that for even $$$n$$$ I can win as First. Here you should be able to come up with some ideas, which is achieved through effort and solving many problems in a wide range of topics. Actually I didn't come up with the idea of "matching congruent numbers in modulo $$$n$$$", so the thinking process ends here for me. I am pretty sure that I would solve it if I had solved enough amount of problems before the contest. Solving $$$x$$$ number of Game theory problems means (at least) $$$x$$$ number of Game theory winning strategy ideas most of the times. Solve problems, be red.
First thanks to you for raising the concern as to why people downvote me.. Secondly a hell lot of thanks to you for writing this awesome advice...I shall try to follow your words. One doubt that I raised in an earlier comment above is what should each player focus on..making the other one play a losing move or playing a winning move for oneself?
Playing a winning move and making the other to play a losing move of course. It may happen that thinking about one of them is easier on some problem, and the other on some other problem. You should try all of your ideas when solving a task.
You may think of a digraph (actually a DAG in many games) which each vertex is a state, which describes how is the situation of the game right now? For example in 1404B - Tree Tag, an state is pair of (Alice's current vertex, Bob's current vertex), so we have $$$n^2$$$ vertices. I can't imagine a graph for 1404D - Game of Pairs because that game doesn't have step moves and the game has only one move for each player.
So if the graph is a DAG meaning there is no cycle in the game (The game ends without even considering the moves of two players) You can label each vertex as a Winning state or a Losing state. A winning state is a vertex which has at least one edge going through a Losing state vertex, and a losing state has no edge going through another losing state. The set of losing state vertices is called Kernel in terms of graph theory. An edge going through a losing vertex is a losing move, and similarly an edge going through a winning vertex is a winning move. I don't know any English resource for learning basic game theory ideas (May be cp-algorithms), but surely you'll find a nice one using Google.
Why is this downvoted??
Probably low quality.
Is there a reasonable reason to downvote this blog? Really I'm eager to know.