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

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

Hello Codeforces!

evima, yosupo and I would like you to participate in Codeforces Round #286. It will be held on Sunday, January 18th at 16:00 MSK. Please note that this round starts on unusual time.

Great thanks to Zlobober who helped us prepare this round, Delinur who translated statements into Russian and MikeMirzayanov who created Codeforces and polygon.

This is the 3rd time(following #162 and #263) for me, and the 1st time for evima and yosupo to prepare a Codeforces Round.

Scores of the problems will be

500-1000-1750-1750-2500 for Div.1, and

500-1000-1500-2000-2750 for Div.2.

In this round, you'll help a man named Mr. kitayuta. I hope he will participate :)

The system tests are now over! The top-5 are as follows:

Div.1:

1.ilyakor

2.kcm1700

3.LayCurse

4.RomaWhite

5.TankEngineer

Div.2:

1.Konijntje

2.cpcpc

3.zgzjsxshycxksxhsh

4.Ronnie007

5.sha384

Also, special congrats on Petr, who solved problem E in Div.1, which anyone else could not solve.

Here are the editorials

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

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

Will there be Appleman again in this problemset? We all really loved this hero last time... Especially guys from Russia:)

Upd. Oh, i see now... So sad, we all miss Appleman. Hope to see him in your next round.

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

Oh, great! The 'unusual time' is suitable for Chinese coders ;-)

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

This is the 3rd time(following #162 and #263) for me

Hope round #364 will be yours, too. :D

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

"this round starts on unusual time" = start time is 5:00 am here. :(

Seems I can't participate Chinese and Japanese contests anymore..

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

hello dis like me pls

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

Score distribution already published. Thanks!

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

Mr. Kitayuta has registered to the contest.

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

Facebook HackerCup is running right now... I thought this would be delayed to after Hackercup or something...

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

I can't join this round cause i have English class...

Why you don't define a specified time for contests? So we can planning for them...

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

    Maybe someone else would have an English class at another time :D

    But it's clear that this is for the problemsetters' convenience.

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

Lets just hope this contest goes fine and rated. :)

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

мне только что пришел клар по задаче Д! С чего бы это? UPD завтыкал, что уже идет раунд, перепутал время до начала и конца

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

Codeforces just changed it's logo to default. Codeforces changed it's logo to christmas.

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

Либо это раунд такой, что я за час не смог даже идеи придумать по A div1, либо это несколько часов решения facebook и написания курсача дают о себе знать. Пойду что ли дальше делать курсач.

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

    Мне тоже не понравилось. У меня конечно нет достаточного опыта, но, думаю, надо было дать нескольким людям разных цветов порешать задачи до контеста, и такой проблемы бы не было.

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

    Есть довольно объективный критерий "гробовости" раунда — сравнить число участников в мониторе и число зарегистрированных участников.

    Сегодня результаты этого сравнения даже не требуют дополнительных комментариев.

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

I think It was so hard; no right submissions for E. 1 right submissions for D. 33 right submissions for C. Wasn't it?

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

I'm solved Div1 D, but I'm too scared to submit it :D

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

Tried to hack 10^8 complexity solution, but unsuccessful attempt, code runs in 540 ms, is that possible??

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

What was the solution of A? :)

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

    Normal DP with F(i, j), where i is current position and j current jump length, but notice that j won't vary that much (~250).

    Edit: I came up with this in the last minutes. T_T

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

      How do you know that j won't vary?

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

        If it changes more then 300 there has to be more then 30000 positions :)

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

        Not a formal proof, but this was my thought: Assume you have i = 0, and j = 1 and you increase the length after every jump. At approximately j = 250, you will jump over the 30000 mark.

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

        Can somebody tell me why this code got TLE? I used the same approach but recursive :)

        http://codeforces.com/contest/505/submission/9462104

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

          AFAIU from your solution, you are caching only answers when jump length < 400. So if initial jump length was big (like 1000) you are calculating answers (for same input values) many times.

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

            Thanks for going through my code :) Will try to correct it tomorrow.

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

      I had to do something wrong, probably everyone in DIV1 tried this, but for last test case the cache had almost 5M states...

      My code on ideone (but RE, because stack size is small)...

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

    Imagine the game is finished, and your final jump length equal to j. It can be proven, that |j - d| is . That's why you can write dynamic programming dp[position][|j-d|].

    UPD. The simple thought that can help you prove the fact. Imagine you start from the very start, and you have d=1. You cannot finish with large d, because almost equal to n.

    UPD2. Fix a mistake, thanks Svyat.

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

Tasks beautiful, but very difficult, IMHO.

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

i couldn't even solve A. Shame on me :(

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

    Don't worry, 1364 registered for DIV1 and only 362 solved problem A :-D

    We all will be kicked out of the division :-D

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

Как решать D(div.1)? Очень уж интересная.

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

    У меня корневая.

    Для цветов, у которых много ребер — сделаем DSU по всему графу и просмотрим все запросы втупую — таких цветов будет немного.

    Для цветов, у которых мало ребер — для каждой вершины просмотрим все доступные из нее по этому цвету, и проверим, есть ли такие запросы. Это мы тоже можем сделать, потому что если мало ребер данного цвета — то и компонента связности будет маленькой.

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

      И сложность будет N*sqrt(N)?

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

        У меня еще сверху логарифм из-за различных map'ов, set'ов, sort'ов и т.д.. Вероятно, можно от него избавиться, но я оставил так.

        Upd. Да, за секунду проходит.

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

    По-моему, тут работает наивное решение. Запишем для каждой вершины пары "цвет, номер компоненты связности по этому цвету, которому принадлежит эта вершина".

    Дальше при запросе будет тупо проходить вектор пар для вершины, для которой этот вектор короче, и проверять, верно ли для второй вершины, что по такому цвету она в такой же компоненте.

    Проверок, как ни странно, будет в сумме O((N + M)3 / 2) — для вершин, у которых этот список длиной меньше корня, это очевидно. Для вершин, у которых список длины больше корня, суммарное число проверок для пар со всеми остальными вершинами не привысит М,а самих таких вершин не больше корня.

    Значит, если кешировать ответы для уже пройденных пар и использовать для проверки, какая у вершины компонента по цвету, хэшмап, получим общую ассимптотику O((N + M)3 / 2). Вроде все верно?..

    А теперь посмотрим, пройдет ли у меня это с мапом и дополнительным логарифмом сложности:)

    UPD: Нифига себе, хвала могучему кодфорсесу! Прошло за 1.1с, однако..

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

Can anyone explain to me how to solve DIV2 C ?

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

Argh, you could have been a little more generous with the time limit of div2c, a n^2 solution with unordered_map didn't pass, but could do any input on my machine in < 3s.

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

Can anybody here tell me why this code gets MLE?

#include <bits/stdc++.h>
using namespace std;

const int N = 1e2 + 5;

int parent[N][N];

int find(int c, int v) {
    if (parent[c][v] == -1)
        return v;
    return parent[c][v] = find(c, parent[c][v]);
}

void unite(int c, int u, int v) {
    parent[c][find(c, u)] = find(c, v);
}

int main() {
    memset(parent, -1, sizeof parent);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        unite(c, a, b);
    }
    int q;
    cin >> q;
    while (q--) {
        int u, v, ans = 0;
        cin >> u >> v;
        for (int i = 1; i <= 100; ++i)
            if (find(i, u) == find(i, v))
                ++ans;
        cout << ans << '\n';
    }
}

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

    Infinite reccursion. You don't initialize values of parent with parent[c][i] = i
    And in find:
    if(parent[c][v] =  = v)

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

      I implement it using this approach:

      init:

      parent[c][i] = 1

      and in find:

      if(parent[c][v]==-1)

      initially parent of all vertices is -1 then in find (parent of a vertex with parent -1), is itself.

      sorry for typos, I'm writing with auto-correction using a phone!

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

    It will fail with this testcase:

    4 4 1 2 1 1 3 1 2 3 1 2 4 1 0

    You do not check if they are already in same component and the recursion never ends.

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

My thoughts while trying to solve Div1.A and Div1.C (it's 2 MB gif).

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

A good contest.I only submit div A & B... Maybe My rating will decrease!

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

Why is it that during each and every Codeforces contest, you can't access the site when you need it the most? In the first 30 minutes, I could view other's solutions. But after that whenever I tried opening someone's solution, it just gave me a blank screen. It didn't work even after refreshing the page multiple times. So I couldn't even TRY to hack a solution!

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

Heh. I never expected that there will be a time when someone with rating 2484 will ask about it, but — how to solve A :D? D was the easiest one on this contest xD.

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

Why Petr try so hard to solve E instead of other problems? It lands him in 117th :/

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

Codeforces needs to at least have one approachable problem in Div1.. otherwise the majority of participants will not submit, meaning those who eventually do solve a problem will have a low ranking..

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

    D was easy :>. Only one in that contest :D

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

    Hmmm... you're totally right. After 0,5h of contest when I haven't got any idea how to solve any of those problems I considered not submitting anything : p.

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

    I though, that once I'm registered, I'm competing — I expected my rating to be changed, even when I had no submition... On TC once I open the problem, my rating would be changed... But in fact the one who solved problem and ended at the end, his rating change is worse then mine, I think this is unfair...

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

Nice problems! Has someone any idea for Div2-C instead of TLE naive recursion + memoization?

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

How to approach Div1 D, it is an extension of Div2 B with larger constraints..

Div2 B could be solved by making m graphs, but how to approach the same problem if m is as large as 10^5?

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

Could someone explain the idea of div1C solution?

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

    Didn't submit (edit: Accepted ), but here's what I thought during the contest:

    You want to simulate to see if a certain max_height is possible, then you can use binary search to get final answer. Hit the bamboos from the last day to the first day. Every bamboo i has to be hit before you get to a certain day hit_by[i] on the reverse simulation -- this means that even if you use all hammers possible on bamboo i before hit_by[i] you will not decrease height of bamboo enough, so you need to hit it at least once on a day after hit_by[i].

    I haven't proven it formally, but I think greedily hitting the bamboo with the largest hit_by works.

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

      Hm, I didn't get your idea. Can you explain the meaning of hit_by[i]? Why can you go from the end to the beginning? I mean, when you decide to do something in the very end, and then cut some bamboos before that moment, your final decision now possibly becomes wrong. Have I missed something?

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

        hit_by[i] means: I have simulated some hits at the end so far. If I hit only bamboo i for the first hit_by[i] days and then hit at the end according to the simulation, I will be able to get bamboo i to a height smaller than max_height. But if I only hit bamboo i for the first hit_by[i]-1 days (other than simulated hits), I won't be able to get bamboo i low enough. This means I definitely have to hit bamboo i at hit_by[i] or after.

        I don't understand why going from the end to the beginning would change the answer. When you do a cut the only thing that changes is the new target (I wanted less than max_height height by day m, now I want less than P height by day Q). If you go in the forward direction, then it's complicated because it's true that a cut affects a lot of other things.

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

    My solution is based on the idea that it's optimal to hit a tree when its height is less than P at most once per tree. If this is true, then that hit should be at the first moment when (tree's height)  ≥  (tree's final height if left unchecked — target height) % P.

    I don't have a proof for that, though, so we'll see what happens in systests...

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

Well, we feel sorry that the problems were too difficult. Actually, we felt all of the tasks were a bit more difficult in comparison with other problems of the same scores, but I hadn't expected that there were such a few submissions&accepts.

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

    I think such difficulty is good, AS LONG AS there is at least one problem that 75% of participants can solve (and it is the first problem :P)

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

    Median of times I need to came up with solutions to B problems is probably less than a minute and here I didn't have any idea how to solve A and B took me something like 30 mins xD. Though I like hard problems, so this contest was really fun for me, because problems were interesting and that's what really counts :)!

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

    Hard problem's have benefits . Solve hard problem to learn a new something :)

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

just to know ... why it gives me time excess (something like that) when i open a solution to hack and then i can open it another time!!

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

1500-1500-2500-1000-2500

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

ENOUGH TO ENDURE!

I have strong disire to view code highlighting in hacks. I'm so tired to recognize 1's and l's.

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

Does the following algorithm for Div1B work:

find the number of connected components (assuming each edge is bidirectional); let it be a

find the number of such connected components that have a cycle (with directed edges this time); let it be b

Our answer is (n — a + b)

I tried this, so either this algorithm is wrong or I'm bad at implementation :P

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

    The same algorithm passed pretests here.

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

      may you explain the analysis for this problem?

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

        For a connected component with n vertices (if we consider the edge is undirected), the answer maybe n-1 or n. If the component doesn't contain any circle, then we can have a "line" that go through all the vertices making a graph that satisfy our condition (the order of vertices the line go through is in the toposort array) And if the component has a circle, what happen now? We can not make a toposort, then the answer can not be n-1, in this situation we just simply make a big "circle" that go through all the vertices (or we add an extra edge that go from the last element to the first element in the toposort array), then we will need n edges.

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

      Will it work on the next testcase?:

      7 8
      1 2
      1 3
      2 4
      3 4
      4 5
      4 6
      5 7
      6 7
      

      The testcase looks like: <><>

      We still need here 8 edges, but we don't have directed loops here. Or it's possible somehow to come up with only 7 edges here?

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

        Just consider topological sort, and connect neighboring vertices (here, 1->2, 2->3, 3->4, 4->5, 5->6, 6->7).

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

        I guess correct answer is six: just connect i-th vertex to (i+1)-th: 1 → 2 → 3 → ... → 7

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

        Wouldn't the answer to that be 6? 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7

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

        answer is 6:
        1 2
        2 3
        3 4
        4 5
        5 6
        6 7

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

        Right answer can't be more than N, because we can make one loop with N edges, where from each vertex you can reach any other

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

    The algorithm is right

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

    Consider this case

    4 4 1 3 1 4 2 3 2 4

    a = 1 b = 0 Answer = 4 — 1 + 0 = 3

    If my understanding of the problems I right, answer should be 4.

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

      No, the answer is 3; you make the edges 1 → 2, 2 → 3, 3 → 4.

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

        Right, thanks. From the start i was thinking of given m edges, remove as many as possible without disturbing connectivity. Screwed it!

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

    It should work.

    If you have a component that contains a cycle, you need to make at least one resulting cycle, so you need at least as many edges as the number of vertices in that component. It's clearly optimal to put all vertices on one cycle.

    If there's no cycle, you need at least (number of vertices)-1 edges; a DAG can be transformed into a path without failing any rules, and a path has the required number of edges.

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

Can someone tell me one thing, please? What is the point of having one extremely easy problem and one easy problem and 3 almost unsolvable problems for Div2 participants. Then you have list where 60th participant solved A and B, as same as someone who is 800+.

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

Next competition is only div 2,maybe I solve something :)

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

What's wrong with system testing?

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

I opened results before system testing and saw this

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

Pending system testing...................?

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

Hey, let's start system testing! I want to see these red->purple and green->gray xD

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

Thanks you! Nice contest :D

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

I think system testing is deterioration

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

What's going on? 45 minutes has passed since the contest has finished!

I guess the rating updates will be fast as (because) the system testing is slow!

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

I think Codeforces is broken. Take a look at "Pay attention" area...

UPD: Already fixed.

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

The unusually long wait for the programs to pass the system tests is adding to the anxiety, especially for those expecting a rise in ratings after the contest

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

How to solve problem D of Div. 1? Why many people say that it's easy? Thanks a lot.

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

Second hour just began...

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

Anybody else read Problem B statement wrongly? I thought only "edges" on input are allowed to make teleportation graph...

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

The system testing is delayed due to verifying test cases(not a technical reason or trouble in the judge server). We feel really sorry about this.

The problems are so hard, even round author can't solve them.

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

    The round author should have thought about it when he decided to be the round author. :) They have to be sorry anyway, it's a long delay.

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

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

I resubmitted D a couple of times because I saw I went over the memory limit (259900KB, but still Pretests Passed). 9463550

But it looks like my fears were unfounded, because the same submission, using even more memory on system tests, still got Accepted. 9465410

Oops.

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

Ничего не сдал -> не спустили рейтинг, кажется я придумал, как на этом заработать :)

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

rng_58 , It doesn't matter what is your rating (or rank)! we will always be your fan!!

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

I will start crying now...

Test: #12 ... verdict: WRONG_ANSWER
Input
1 30000
30000
Output
0
Answer
1
»
9 лет назад, # |
  Проголосовать: нравится +20 Проголосовать: не нравится

Не понял, куда пропали рейтинги?

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

The ratings are back to the last ones???

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

Mmm, guys, what has happened to ratings?

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

WTF , I had +55 but now it is +50 , why ???

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

It seems that i've just set a new record for shortest period of being IGM (~20 minutes, i guess :) )

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

Can anyone tell what's wrong with my DFS for Div.2 B? Each node has a vector of pairs <color, endnode> and then it just tries to DFS through all the colors, but I can't figure out why it doesnt work. :/ http://codeforces.com/contest/505/submission/9461069

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

    I don't know what your algorithm does but here is a simpler way:

    for every possible color see if there is an x-to-y path with that color only (x and y are query vertices).

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

      Yeah I tried to figure out a path from the start vertex to the end vertex by just recursively checking the neighbour nodes of the following vertex and if the edge color was the same then continue searching until the end. However for some reason my implementation is not correct.

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

I just can't understand how the rating works.. rng_58, whose rating was 2782, got -107. But Antoniuk (whose rating was 2244), and -imc- (whose rating was 2256) both got -102. All of them got 0 points in this round. How could this be possible?

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

    It is ovious even for me=). rng_58 have higher rating then Antoniuk and dragonic, so his rating dropped down most. Antoniuk and dragonic have same decreasing, beacause of rounding, rating calculates in double then rounds to int. Read about Elo rating. Sorry for my bad english.

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

      You may be right. Thanks for your comment, I'll read about the ratings :D

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

    There exist some threshold — you can't lose more than X points, no matter how bad you perform. I don't know how value of X for given user in given contest is calculated, but usually it is around 100 points (or a bit more).

    When you are violet — it is really hard to hit this limit; for red users it is much easier (placing somewhere in the middle of the standings is enough), and for top-users it is even easier — tourist once got -135 for 21st place.

    And also — look how dreamoon_love_AA was getting -110..-120 for placing last :)

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

      I was just suspicious because I got -111 last round, for only solving B. (my rank was 366/610) I think the reason is that the problems of this round were really hard than the last round's problems..

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

Will this algorithm work for div 2 D?

  • Find strongly connected components,
  • Turn each SCC to a cycle and keep the remaining edges.
  • »
    »
    9 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    No. The correct algorithm is above somewhere. (look for Div1-B instead of Div2-D)

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

Many Accepted codes of Div-1 A/Div-2 C crushes for this input:

1 1 30000

Is the input invalid? Or, judge data is weak?

This Accepted Code Crashes for the above input.

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

    It's invalid, because there are 30'000 islands in total, not 300'000.

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

      Sorry for my mistake, it was actually 3*10^4. I have updated the input now and have added a link of a acctepted code that fails this test case.

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

    My prog return 1.

    I guess this is correct answer.

    UPD: Sorry, didn't notice 3*10^5, not 3*10^4

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

      i actually meant 3*10^4. but, somehow miss-typed 3*10^5. Sorry for my mistake... i have updated the input now. :) and, i have also added a link that fails this test-case.

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

    Test case #18 is exactly yours.

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

      i don't get it... why this code would crush in my system while it works fine on Codeforces??

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

        Just a guess: undefined behaviour.

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

        f ends up recursing roughly 30,000 times; my guess is you got a stack overflow.

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

          i guess too that it is caused by stack overflow. But, don't you think, PC got more space than virtual judge for stack memory? although, i am not sure which one got more space for running a program!! :(

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

For Div1-A/Div2-C, Could someone help me figure out why does 9462290 TLE at test 5 but 9467397 gets AC? The only difference is I change the memoization from a map to an array keeping the difference with d.

Shouldn't the two essentially be the same ?

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

    std::map has O(log n) access time, not O(1). AFAIU std::unordered_map has sort-of-O(1) access time, but with bad constant. I also failed to solve this problem with unordered_map, but got AC with plain array.

    BTW, my array solution works 5x times faster than yours, probably because I also use array for gems variable (and you use map).

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

      I know that a map has O(logn) but that should still make within the time limit, right ?

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

        As we can see, it shouldn't :(

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

          I guess map is actually slow and I should be more cautious using it then. It seems to have a very large constant factor and does allocations for each object hence its slowness.

          I found this:

          std::map has similar characteristics to std::set: it uses a single allocation per pair inserted into the map, it offers log(n) lookup with an extremely large constant factor, imposes a space penalty of 3 pointers per pair in the map, etc. __ std::map is most useful when your keys or values are very large, if you need to iterate over the collection in sorted order, or if you need stable iterators into the map (i.e. they don’t get invalidated if an insertion or deletion of another element takes place)

          source: http://llvm.org/docs/ProgrammersManual.html

          EDIT: Hmm I just tried changing my code in Java to use a HashMap which has O(1) 9467938 but it also gets TLE at test 5..

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

    Thanks for posting this, I'm practically in the exact same situation. My solution is here: http://codeforces.com/contest/505/submission/9467923 and theoretically its complexity is at most around 30000*500 operations, which should be acceptable. However, since these operations are on maps, it appears the very large constant factor does its tricks. I expected my solution to either barely pass or just barely get TLE, but it turns out it takes ages to produce a solution, tens of seconds on my machine. Honestly, I'm pretty shocked at how slow the operations on maps are in this case. I guess this is a good lesson for me on how well modern processors can handle contiguous data (vector) vs. not-so-contiguous (map).

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

    So do I. Even I changed map to unordered_map, still got TLE.

    A tough lesson, QAQ~

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

2 years ago Coder noticed that Petr and tourist couldn't solve C which was also E for div2 and made this comment: http://codeforces.com/blog/entry/5586#comment-108611

What to say today about Petr and rng_58 :)?

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

Meh. It's good to have basic knowledge about STL...

This got TLE and used 198MB: 9459485

And this easily passes all tests using 23MB: 9469360

The only difference is changing

res += (pars[c][u] == pars[c][v]);

to

if (pars[c].find(v) != pars[c].end() && pars[c][u] == pars[c][v]) {
    res++;
}
»
9 лет назад, # |
  Проголосовать: нравится +42 Проголосовать: не нравится

Finally, after 93 contest I'm in div1 I'm so happy!

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

I pass Div1 A and D both through brute force. So lucky and maybe the test cases must be more careful.

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

Where is the editioral?

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

    It is currently being written. The first part (all problems except Div1C(2E) and Div1E) will be ready within approximately 4 hours. Thank you for your patience.

    Edit: sorry, I had to insert one word into the sentence above.

    Edit2: The first part has been published here. It actually took 8 hours after I posted this, sorry for being late.

    Edit3: Added Div1C(2E) and the problem setters' codes.

    Edit4: Added Div1E. I am sorry to have kept you waiting.

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

When will the editorial be out?

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

problemset was tough but very nice , problems required more thinking instead of coding that means quality contest.

Congratz to authors !!!

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

I can't open editorials

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

Why my solution get WA on test 10? I can't see anything wrong in my solution...

My solution

Please help me!

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

excuse me, for this easy sample : 6 7 1 2 2 3 3 1 3 4 4 5 5 6 6 4 the output is 6, it is not 7, why ?

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

Can anyone help me and explain why my solution is failing for Div1 Problem A. My Solution id is : 9666602