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

Автор divya8080, история, 10 месяцев назад, По-английски

I was trying to solve this problem: https://mirror.codeforces.com/contest/1487/problem/C and i came up with a wrong solution that i changed, now i know this modified solution works but its based on some assumptions that are:

  1. if n%2 = 0, then the optimal way is to tie a match between two teams such that each of them has no ties yet. And there is a way to get score = 0, in a way such that we make a team lose (n)/2-1 times and win (n)/2-1 times and 1 tie(assigned previously), also if this team has won/lost a match with any other team, we keep that in mind. So, we fill the grid of size n * n, such that each row(representing a team's matches has sum = 0), one thing that i need prove with is that once i have filled more than n/2 rows its possible to fill remaining such that their sum if 0, and only using -1/0/1 representing lose/tie/win.
  2. else, the optimal way is to have no ties and make each team lose (n-1)/2 times and win (n-1)/2 times. Here, i needed proof with :- Once I have filled more than n/2 rows, its possible to fill remaining with sum = 0 using only -1/0/1 representing lose/win/tie.
  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

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

Could you please try to write your statement more clearly? I can't be sure about what you mean by "Once I have filled more than n/2 rows, its possible to fill remaining with sum = 0 using only -1/0/1 representing lose/win/tie".

If you mean that you can fill up the first $$$(n + 1)/2$$$ rows arbitrarily keeping row sum = $$$0$$$, there will always be a way to fill up the rest of the rows keeping row sum = $$$0$$$, then that is wrong.

Here's a counter example:

v 1 2 3 4 5 6 7
1 X W L L W L W
2 L X W W L L W
3 W L X L W L W
4 W L W X L L W
5 L W L W X ? ?
6 W W W W ? X ?
7 L L L L ? ? X

No matter how you replace the ?, you will not be able to ensure equal number of wins and losses for each team.

If there are some specific rules which you are following to fill up the first half rows, please specify it.

  • »
    »
    10 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    yeah this way only, making sure that if grid[i][j] = W then grid[j][i] = L and vice versa. and keeping sum = 0, i see, this is wrong thanks for providing example.

  • »
    »
    10 месяцев назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится +3 Проголосовать: не нравится

    i tried it, it works

    this is the output for n=7, first i assign 'L' or losses to a team(except for matches that have already taken place keeping in mind match[i][j] = negation of match[j][i])

    X L L L W W W
    W X L L L W W 
    W W X L L L W 
    W W W X L L L 
    L W W W X L L 
    L L W W W X L 
    L L L W W W X
    
    • »
      »
      »
      10 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится +1 Проголосовать: не нравится

      So, if I am team $$$x$$$, I beat team $$$x+1$$$, $$$x+2$$$, $$$...$$$, $$$x + m/2$$$ and lose the rest of the matches (in case $$$x + i \gt n$$$, I take $$$(1 + x + i) \mod n$$$). This is symmetric for all the teams (if I beat $$$x + i$$$, $$$x - i$$$ beats me), so the interdependencies are handled. For even $$$n$$$, $$$x + n/2$$$ and $$$x - n / 2$$$ are the same teams (in circular number line), so I can assign a tie there.

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

    and for n=8, this is the output,

    initially i understood the scores wrong in case of winning, winning team gets +3 and losing team gets 0 in case of tie, both get +1

    for n = 8, this is the output, T=tie

    v 1 2 3 4 5 6 7 8
    1 X L L L T W W W 
    2 W X L L L T W W 
    3 W W X L L L T W 
    4 W W W X L L L T 
    5 T W W W X L L L 
    6 L T W W W X L L 
    7 L L T W W W X L 
    8 L L L T W W W X 
    
»
10 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

I tried it by exploiting the properties of permutation, like teams are ordered 1,2,...n which is a permutation. Let n = 5, initially i assumed all teams have tied with each other and if tie is resolved (i.e conclusive result), each team would have to face equal number of wins and losses. say at a leap of 1, i.e 1 -> 2 -> 3 -> 4 -> 5 -> 1 (forms a cycle), where "x -> y" means "x defeats y". Similary at leap of 2, 1 -> 3 -> 5 -> 2 -> 4 -> 1, and so on. However, some cycles are defective, like for n = 6, leap = 3, 1 -> 4 -> 1, as 1 defeats 4 and 4 too defeats 1, which is not possible, and hence tie cannot be resolved. Though my approach is too complicated.