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

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

Remember to register.

--- EDIT, the contest is over ---

BearBall, 250 points

There is a special case when all points are in one line. Otherwise, for any pair of bears the number of throws is 1 or 2.

So, for each points you should count how many points are directly reachable from this one. You achieve it by sorting other points. The complexity should be .

Proof that 2 throws are enough
code for BearBall

BearGridRect, 600 points

Hint: use flows, maybe mincost.

what graph?
code for BearGridRect

BearCircleGame, 800 points

Dynamic programming. Iterate over the number of remaining players, from n to 1. In each moment, you need an array of size with probabilities — for each number of bears what is the probability that Limak is this far from the starting bear. Then, for each bear we need probability that he loses and thus we will know the next array (for remaining - 1 remaining bears).

a loses with probability .

Try to first write O(n3) approach — find cycle in a sequence of indices a + 1 - k, a + 1 - 2k, a + 1 - 3k... and then over indices in the cycle sum up where c is the size of cycle and d says which place this index has in the cycle.

To make it faster, notice that the answer for a and for a + k will be similar. It's enough to multiply (or divide, whatever) by the sum by two, and then add one value.

code for BearCircleGame

WINNERS

  1. liymsheep, who solved all three problems
  2. ACRush
  3. kriii

And congratulations to Petr for solving all problems and thus winning the parallel round.

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

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

That was a bit of spoiler.

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

Btw, problem 600 can be solved without using mincost-flow, but using an LR-max-flow algorithm (for finding maximum flow when there are lower bounds of flows for each edge).

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

What's wrong with the solution using bfs for the 250 pointer ?

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

Why did you set the time limit for the 800-pointer two times the usual 2s?

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

    I tried to write my Java solution to be as slow as reasonably possible. It requires ~2s for the current constraints so I chose 4s to be TL.

    But you may ask why I chose high constraints. Well, to not be afraid about O(n3) approach. In hard problems it's a disaster when people get worse complexity accepted so it's very convenient for me to set high constraints. I think that everything would be fine today with lower constraint for n but I also don't see important pros.

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

    Slightly unrelated, but what tool are you using for opening problem statement in browser and coding in Dev C++ instead of the arena?

    It is really tough to use the arena(UX wise)

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

      Actually, I just started to use Greed and I like it. Previously I used KawigiEdit. There are some nice posts about Greed on Vexorian's blog. For what it's worth, my config is the following:

      greed.codeRoot = "./../.."
      greed.language.cpp {
        longIntTypeName = ll
        templateDef {
          source.templateFile = "template3500.cpp"
          source.afterFileGen {
            execute = "C:/Program Files (x86)/Dev-Cpp/devcpp.exe"
            arguments = ["DOLLAR{GeneratedFilePath}"]
          }
          problem-desc.afterFileGen {
            execute = "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"
            arguments = ["DOLLAR{GeneratedFilePath}"]
          }
        }
      }
      

      (replace DOLLAR with dollar signs).

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +38 Проголосовать: не нравится
  1. qualify to TCO round 3 (from 39th place where top40 advance, so that's neat)
  2. read up that this year, FOUR PEOPLE PER ROUND (3a/3b) advance to onsite
  3. ...profit?
»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In your code for BearCircleGame, I believe that is a geometric series not an arithmetic series. Please correct me if I'm wrong.