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

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

Hello,

Indonesia is hosting this year's APIO 2015. The contest will take place on this weekend, May 9 2015.

We also provide a mirror contest, called Open APIO 2015, after the official contest day for everyone to participate. It will be a 5-hour virtual contest that you can start any time between Sunday, 10 May 2015, 20:00 (UTC+7) and Monday, 11 May 2015, 20:00 (UTC+7). We really encourage you to try the problems, just for fun!

Here are the details:

  • Register here: https://competition.ia-toki.org/contests/18/view. Registration closes 1 hour before Open APIO 2015 ends. If you don't have account on TLX (our contest system), you will be prompted to register on TLX.
  • No medals/certificates will be awarded.

The rules for Open APIO 2015 are similar to the official one:

  • There will be 3 IOI-style problems.
  • You can only submit at most 30 submissions for a problem.
  • You will get full feedback for each submission.
  • For each problem, there are several subtasks:
    • For each subtask, there are points assigned to it.
    • Each subtask contains several test cases.
    • You get the points from that subtask if the program passes all the test cases in that subtask.
  • The score of a submission is the sum of all the points that you get from completing subtasks.
  • The final score for a problem is the maximum of all the submission scores for that problem.

And here are the grading environment specifications:

  • OS: Ubuntu 14.04.1 LTS
  • Kernel: Linux 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64
  • CPU: Intel Xeon E5-2666 v3 2.90GHz
  • Compilers:
    • gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2 (flags: -O2 -lm)
    • g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 (flags: -std=c++11 -O2 -lm)
    • fpc 2.6.2-8 [2014/01/22] for x86_64 (flags: -O2 -XS -Sg)
  • You must print a newline ('\n') after each line in your output.

You can also discuss the problems on this thread, but please do so after Open APIO 2015 ends.

Thanks,

APIO 2015 organizers

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

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

Dying of curiosity. In which countries APIO'15 have already been held?

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

    Currently all countries registered in APIO have already finished their contest:

    1. Armenia
    2. Australia
    3. Bangladesh
    4. China
    5. Hong Kong
    6. India
    7. Indonesia
    8. Iran
    9. Israel
    10. Japan
    11. Kazakhstan
    12. Kyrgyzstan
    13. Macao
    14. Malaysia
    15. Mongolia
    16. New Zealand
    17. Philippines
    18. Singapore
    19. South Korea
    20. Sri Lanka
    21. Syria
    22. Taiwan
    23. Tajikistan
    24. Thailand
    25. Turkey
    26. Turkmenistan
    27. Vietnam
»
9 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Is there anything wrong with the grading system?

After I have submitted my solution, it shows "Pending" for a long time. After that, it became "Internal Error".

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

When will you publish results?

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

Hello everyone. I would like to ask a question. On this website (http://www.apio2015.org/schedules.html) it is written that today, there are Unofficial result — Unofficial results of this Official participants ?? Thanks in advance.

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

Sorry for the delay of the unofficial results. We are currently in the process of compiling the results.

Thanks!

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

Well was i too late for the contest? (open one)

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

Why don't we tell our own scores while waiting for the results?

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

Nice problems, I like it when the problems are more about thinking then coding.

The downside is I wouldn't be surprised if there were many people tied with 300 points...

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

I am sorry to say, but problem's quality was much lower than last 3-4 years.

First of all 120 points were requiring shortest path algorithms:( and another 80 from first problem was easy dynamic programming.

Also third problem had 63 points which has limits N <= 1000 or K = 1. And those 63 points was not worth it.

Seriosly why just 37 points for the last subtask which is the only interesting and non-standart one?

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

    Hint: I wrote problem B, and I forgot to increase the constraint for N to 1,000,000,000 (originally, we were planning to allow only (N+M) sqrt (N+M) solutions to pass. But, we're lenient, so we allow (N+M) sqrt (N+M) log (N+M) to pass too. But then, the constraint should have N <= 10^9).

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

      Saddest part is, a lot of people with 100 points did not even noticed it was .

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

        I agree! It's even sadder since some of the test cases are rather weak.

        (now... let's focus on the N <= 10^9 version. Can u solve it? Edit: can anyone solve it?)

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

          Sorry for necroposting, but can someone explain the solution for N <= 10^9 variant of the problem?

          I tried looking for old analysis's etc., everything gets 404. :(

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

            If I recall correctly, there is nothing written about O(M1.5lg(N + M)) solution in Editorial.

            And now I'm also very curious about the solution too.

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

      I think you meant , right?

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

Really got tired of waiting for the results.
Can you at least tell that will the results be up today or not ???

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

What do you think the medal ranges will be?

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

LiTi and SMAKH both got the 6th place in Iran, which one is gonna be in official results ?

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

how is the solution for the B problem?

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

    First delete doges with equal Pi in the same building, because they make no difference.

    For every doge with power Pi present in building Bi, add an edge from Bi to Bi + Pi with cost 1 (meaning this doge jumps 1 time to the positive direction).

    If there is a doge with the same power Pi in building Bi + Pi, stop adding edges for this doge (jumping further makes no sense because passing information to this new doge and having the new doge jump is the same thing). Otherwise, continue by adding edge from Bi to Bi + 2*Pi with cost 2 and check if there is a doge there with same power, and so on. Add edges similarly for jumps in the negative direction.

    Now just run Dijkstra's algorithm. Dijkstra's is O(E log V) and we have at most O(n sqrt(m)) edges, so complexity is O(n sqrt(m) log(n)).

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

      thanks

      my different was just the "stop adding edge" thing and it cost me TLE :/

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

        Makes sense, without that the number of edges might be equal to nm (imagine a bunch of doges with power 1, for example). I assume this was the difference between the last two subtasks and the rest.

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

      where does the upper limit n sqrt(m) come from? can you explain it a bit more?

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

        I'm not sure I remember the problem correctly, but consider all doges with power P. Each building only gets at most two edges from each direction (since the others would stop before getting there), so the total number of edges is O(N).

        An individual doge with power P also contributes at most O(N/Pi) edges.

        So for doges with power < sqrt(N), there are sqrt(N) different powers so they contribute at most O(N sqrt N), and for doges with power > sqrt(N), each of them contributes at most sqrt(N) so they contribute at most O(M sqrt N) in total.

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

how to solve full A and C problem?

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

    C : the problem is just if K=2. if we have one fixed bridge position x, the cost for each pair bridge (x,y) with increasing y will form a curve (and my friend found that in the bottom of a curve, it is 'not a curve') so, just use ternary search for both x,y , and when left and right bound is close enough, just use brute force.

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

      So we use ternary search for finding "fixed" bridge x first without considering second pair, then use ternary for find bridge y?

      How if choosing the first "fixed" is not the optimal one?

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

    C: (assuming you know how to solve K=1)

    Suppose our pair of bridges is (B1, B2), B1 < B2.

    A certain trip x -> y uses B1 if and only if B1 + B2 > x + y (proof omitted).

    So if you sort all trips by increasing order of x + y, the only possible ways to partition the bridges are: the prefixes of this array use B1, corresponding suffixes use B2.

    For each prefix, calculate optimal bridge position (using solution for K=1). For each suffix, calculate optimal bridge position. You can do it faster than calculating it from scratch for every prefix: use a data structure such as a set to be able to keep median incrementally for every prefix in logarithmic time.

    Then choose partition that gives you smallest total travel time and you're done. Code: link

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

      how to get "A certain trip x -> y uses B1 if and only if B1 + B2 > x + y"?

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

        x,y uses B1 if and only if (x - B1) * 2 ≤ (B2 - y) * 2.

        which means x - B1 ≤ B2 - y, so x + y ≤ B1 + B2.(just simple math)

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

      That's amazing. I can't understand why you could find a such solution.

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

        Of course, the solution didn't come ready -- I scribbled a bunch of bridges and homes on paint before I could see that the cost to choose a bridge for a certain trip was symmetric along the midpoint between x and y (), so I could choose which bridge to go to by taking the closest bridge to that midpoint line.

        From there, it's not such a big jump to sort trips by this quantity, and then you're more than halfway there.

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

      Can you explain the idea behind your data structure?

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

        It's quite easy to add a number to a sequence and update the median using C++ set. Suppose that all numbers are pairwise distinct. Maintain a set, an iterator points at the current median and a variable to count the number of value smaller than the median. Whenever adding a number to the set, update the counter and move the iterator if necessary. Take into account that valid iterator remains valid after insert operations.

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

    Another solution for C.

    Let me denote opt(i) as best second position of bridge if first one is on i.

    I claim that opt(i) ≤ opt(i + 1). After then, while using divide and conquer optimization to calculate the total distances i am using 3 fenwick trees.

    Overall complexity is O(N(logN)2).

    Here is the solution for more details : link

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

7 contestants from China got 300 :p

Although I got 100+100+63 which seems a good score, the competition is tooooooo tough :(((

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

The unofficial results can be downloaded on the contest dashboard. Sorry for the delay.

Also, we apologize for the weak test data. We figured it out in the middle of the contest, and it is unfair if we add new test cases.

Thanks!

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

    Thank you very much :)

    And thank you for not changing the test cases. I played a bit with some unproved solutions (which later, after the contest, turned out to be wrong) and ran out of time and could not implement the correct ones that were in my mind. I was afraid that I will lose those points (9 points :D) which I got using unproved solutions.

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

    Gold only for full scores...

    Never imagined such contest :p

    If the test data were stronger there might not be so many full scores and I might get a chance to get in international ranking :p

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

    Yeah, now I understand why it took so long to publish the (unofficial) results.

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

What is the solution for Problem 1? It seemed like dynamic programming. Can someone share their code?

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится +11 Проголосовать: не нравится
    long long ans = (1LL << 62) - 1;
    for (int bit = 61; bit >= 0; bit--) {
      if (check(ans - (1LL << bit))) {
        ans -= (1LL << bit);
      }
    }
    cout << ans;
    

    check(mask) — returns true if we can divide our array into groups so that sum in each group is submask of mask.

    For first 3 subtasks where A >= 1 (A and B is number of groups) we can write DP[LEN][GROUPS] — can we divide first LEN elements into GROUPS groups. Total complexity will be O(N^3 * 64).

    For last one, where A = 1 we can write DP[LEN] — minimal number of groups so that we can divide first LEN elements. Complexity is O(N^2 * 64).

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

What is the intended solution for problem B with extension N=$10^9$? Can't get any idea for sublinear complexity on N.

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

How can I access problems and the ranking list? I've registered using the above link, but it doesn't show anything when I log in.

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

So when will official result be published? Or we will use unofficial result as official result?

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

    Official results have been announced to country leaders. We will be posting it on the website soon. Thanks!