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

Автор MikeMirzayanov, 11 лет назад, По-русски

Добро пожаловать на 2013-2014 CT S01E09: 2011 German Collegiate Programming Contest (GCPC 2011) + GCJ 2009 R3 C-D. Продолжительность тренировки — 5 часов. Тренировка открыта как для команд, так и для индивидуальных участников. После ее окончания вы можете дорешивать задачи тренировки или поучаствовать в ней виртуально, если не смогли принять участие одновременно со всеми. Пожалуйста, участвуйте в тренировке честно.

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

Регистрация на тренировку будет доступна со страницы Тренировки и будет открыта до окончания тренировки. Регистрируя команду, выберите именно тех её членов, кто будет писать тренировку.

Удачи!








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

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

I just realized that since I moved from summer to winter time, the contest starts unpleasantly earlier. Damn it.

Great pic, btw. Suffix trees: so simple! :D

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

Does it mean problems will be about suffix trees?

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

What does the picture talk about? A book with Suffix Tree or some Suffix Tree problems?

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

For Problem D I used 12! permutations and checking the validity of permutations, Does not anybody has some smarter solution for this?

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

    If you choose 7 values (let's say the first seven minus the pre-defined ones), you can solve a system of equations and obtain the remaining 5. So it's enough to consider at most possibilities for those, and check the validity.

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

      Nice idea :) Thank you :)

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

      To get the lexicographically smallest solution, we should choose 7 special points. If I index all 12 points from up to down and from left to right, we should choose 1, 2, 3, 4, 6, 7, 9. Am I right? Sorry for my poor English.

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

    You can generate permutations step by step and check lines when they are filled. In my solution I checked first line after fixing just 5 numbers, second — after 8 and so on.

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

Sooo, it's finally over and I can ask questions. In the problem B I used dynamic programming to search the largest common substring: dp[i][j] = (similar(s1[i],s2[j]) ? dp[i-1][j-1] + 1 : 0). But I got WA 7. Is the idea wrong?

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

    Not sure, but given the constraints and time limit, it was enough to write an O(N2) bruteforce (try all possible shifts of the 2nd string with respect to the 1st one, find the overlapping parts and count their longest common substring in just 1 linear pass).

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

    it should be correct, I had same implmentation for this. see http://ideone.com/0yTgsj

    initially I was also getting WA 7. Reason being for odd n, I was understanding the atleast half part wrongly.

    Initially I had something like if(ans>=(n)/2)puts("POSITIVE"); else puts("NEGATIVE");

    I changed it to if(ans>=(n+1)/2)puts("POSITIVE"); else puts("NEGATIVE");

    and it got accepted :)

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

      I had "if (ans*2 >= n)".. With your condition no improvement as well :( By the way, there was nothing in the statement about it. Strange as for the pedantic Germans. But, anyway, thanks.

      UPD I found the mistake: i didn't assign zeroes to dp[] array for every new test case. Kind of annoying :( Thanks for your code, I wouldn't have found the error without it.

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

Does anybody know the solution for problem K? I had an idea which was based on the fact that the answer is at most 3 (I noticed some triangle pattern in the corresponding graph), but I can't seem to get past test #5. Thanks in advance.

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

    The graph will be planer graph , so according to map coloring theorem at most 4 color will be needed . So , by using backtracking + prunning you can check for at most 3 color, otherwise ans will be 4 .

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

      Thank you very much for your help!

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

      WAT? Backtrack got AC :|? It seems that tests weren't generated properly :P. There exists a linear solution (which I haven't found)!

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

Any clue for problem L? I am totally out of ideas.

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

    Well.. There is no problem for ideas, there is many problem to write it:) First off all, let's create a solution if we can solve problem by O(n), where n — number of palindromes. Let's called d0 — number of positions where even number of palyndromes in prefix, d1 — number of positions where not even number of palyndromes in prefix. It's easy to understand that total numbers of good subranges is d[0]*(d[0] — 1)/2 + d[1]*(d[1] — 1)/2; OK. How to find d0 and d1 faster? Try to solve it fast for range 10^(k — 1) ... 10^k — 1, that is to all numbers lenght k. Let k is not even, note that if we know last palyndrome and his middle was not '9', we know where is next palyndrome — for distance 10^((k — 1)/2). We can check that all positions before palyndromes with it middle '1', '3', '5', '7', '9' in d1, another in d0.

    But i totally don't know how to write all it fast.

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

Two things:

  1. problem analysis of A-J: here

  2. evandrix sure is amazing here for a green coder: he submitted 10 problems at once and only got 1 WA (and even that on sample).

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

    It looks like he spent the first 4 hours to code and then submitted all of them later lol =)

»
11 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
I found some team include mine couldn't accept the problem K because WA on test 5. I want to know the reason, THANKS. My algorithm is about Perfect Elimination on a chordal graph.
»
11 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I am newbie in sport programming. Couldn't you help me, what's wrong? How to improve this code for problem A? It talks "Runtime error on test 2" http://pastebin.com/4VCEB30Q

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

    Im sure N is big in the problem and your factorial-computing function causes stack overflow.

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

Emmm... Excuse me, could you tell me, how that has happened that during the training so many people got B accepted? Have you got another problem description than me? Or some kind of clarification which was not showed to virtual participants? "Regions of equal length of DNA strings are similar to each other, whenever |(a[i] − b[j])| ≤ 1, where a[i], b[j] are lower-case letters." — this is the worst problem statement I have ever read. Today, some teams from University of Warsaw trained on this problemset and no one understood it properly. Few teams tried many possibilities and coded few different programmes for few different interpretations of this statement and finally got AC but this is ridiculous. And E — maybe even more ridiculous description. Note to self — don't ever train on German problemset — really poor problems (only G required any creativity but still it's not an excellent problem) and statements of B and E were so utterly messed up...

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

    Could you suggest me well-prepared Polish ACM-ICPC contests (differ from CERC)?

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

      In my opinion all contests prepared by University of Warsaw are really good. Enjoyable problems and clear statements. AMPPZ (Polish Collegiate Programming Contest) in 2011, 2012, 2013 were prepared by UW and I think that these are really good contests.

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

    By the way, can you clarify, what that statement in B mean? As for me, I still don't get it.

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

There is analysis only in German for E. Can anybody explain solution(at least briefly)?

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

    The biggest difficulty in this task is to guess the right description, because it is not written anywhere :P. What you should guess is that order in this task matters. If you create B and C from A it is important that B is on left and C is on right (can anybody point me where it is written in statament? I don't think so). And resulting order should be as in the output string. No more diamonds are allowed. If you figure out this statement, the rest is realy easy. Just compute a table dp[i][j][c] which denotes "least cost which lets you transform diamond "c" into whole substring of resulting string from i-th to j-th letter. This can be easily done in O(l^3*r).

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

      Thanks! It's really difficult to understand this task in right way(we haven't done it:) ). But why does this solution work fast? C*L*R*(N^3) — it seems to be large number of operations(even with /4 because of inner loops).

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

Excuse me, but where did you get checkers and jury solutions for GCPC 11? They're not published on the official constest page. I'm asking, because I tried to create the training in the Gym based on GCPC 12, and faced the absence of checkers.