Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Добро пожаловать на 2016-2017 CT S03E02: Codeforces Trainings Season 3 Episode 2 - 2004-2005 Open Cup, Volga Grand Prix. Продолжительность тренировки — 4 часа 30 минут. Тренировка открыта как для команд, так и для индивидуальных участников. После ее окончания вы можете дорешивать задачи тренировки или поучаствовать в ней виртуально, если не смогли принять участие одновременно со всеми. Пожалуйста, участвуйте в тренировке честно.

Ориентировочный старт: 14 сентября 2016 г., 16:10 (Московское время).

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

Условия задач будут на английском языке, ведь мы же готовимся к ACM-ICPC!

Удачи!

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

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

if editorials of season 1 were published or atleast the codes of other people are made visible then it would be quite helpful.. :) thank you.. :)

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

how to a beginner can participate this season ?
thank you :)

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

    go to gym and click in register after the registration be enabled

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

Why does the title say "S03 E01", but the episode is Episode 02?

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

Wrong Ans on TestCase 104 20243522 isn't it more pathetic ? :p

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

Please reopen registration :(

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

Unrelated, but can I use the image in the post as my avatar?

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

Could you give more explanation about the question Fence. What does "if there are two red boards in the fence with the number of boards between them multiple to K" mean?

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

    You should find such i, j (i != j) that:

    1) a[i] is red

    2) a[j] is red

    3) distance between i and j is the number that can be divided by K

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

      So the distance between i = 2 and j = 3 is supposed to be 1 ?

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

        In this problem distance is the number of elements that are situated between i and j

        So distance between i = 2 and j = 3 is 0

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

Testcase 22 in H? :D

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

How to solve H?

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

    For all keep indices xmod that are 1's.

    Segment [l, r] is good, if l mod k = (r + 1) mod k.
    So we just need to check that there are exists modulo mod, such that xmod and xmod + 1 are both non-empty.

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

    Hint:

    Simplified the problem as : Find a subarray of an array whose sum is divided by given number K . If the sum of the numbers in the range [a, b] is divisible by K, then: (∑i=1 to a-1 arr[i]) % K = (∑i=1 to b arr[i]) % K

    Construct a hash-map which will store the cumulative sum of all the numbers thus far mod K.

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

How do you solve E?

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

Can someone tell how to solve I please?

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

    Solution for I.

    Claim: For i subsets, we can partition .

    Proof: Induct. i = 1 is trivial.

    Start with .

    Then, perform

    Then, set .

    It is not difficult to prove that and each T is sum free.

    This solves the problem, since

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

      can u please explain your solution in detail.

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

        http://pastebin.com/Ykmg7iWn

        Let me explain this solution in a better detail.

        First, let us reword the problem.

        Problem: Can we partition the set {1, 2, ... n} into 10 sum-free sets?

        (Note: Sum-Free Set is a set A such that if , .)

        Let us make the trivial observation — if {1, 2, ... n} can be partitioned, so can {1, 2, ... n - 1}.

        Now, we use the Claim above. Since , every n ≤ 25000 is okay.

        Therefore, construct the sets T_1 ~ T_10 inductively as described above and print which set a number is included in from 1 to n.

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

Well, it seems the fact that the graph isn't guaranteed to be connected makes C so much harder (adding edges carelessly to make it connected doesn't work). What was the expected solution?

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

    LOL. You need to connect components by leaves. So much harder.

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

    Each connected component can be compressed as a trees where nodes are biconnected components

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

Can problem B be solved in C++???

all the Accepted solutions were either in Python or Java, I know that it could be solved using the BigDecimal Class in Java, but is there anyway to solve it with C++???

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

Is there any editorial available for this round?

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

Can someone give me idea about G and H just getting TLE there

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

    For G Get locations for each value first. Then iterate over 1 ≤ i ≤ n, and j such that i|j and check if both numbers appear in the sequence. Since , this solution is .

    For L (OOPS) Control two arrays, for color blue and red. Let the number of blue fence be bs and red fence be rs. Clearly, we use min(bs, rs) fences of each color. Sort the two arrays and choose the largest ones. The solution runs in .

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

How to solve B & I ?

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

    B: Just iterate several times . This thing goes to really fast.

    I: Suppose, you know how to color N cells using just K colors. Then using K + 1 colors you can easily color 3 * N + 1 cells, like this:

    { old thing with K colors }{ N + 1 cells with new color }{ old thing with K colors }

    This will give 0110222220110 for 3 colors. Overall it allows you to color up to 29k cells with 10 colors.

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

      Could you explain your solution for problem B in detail ?

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

      Nice and simple explanation for problem I.

      I was far from this solution trying with binary operations and congruences, and I solved up to 3125 :(

      I wonder if there is a different approach.

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

      Can that B solution pass with C++ too?

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

        Apparently you need some king of long arithmetics here. Usually the best way in this case is to either use Java or Python.

        If you are brave enough and can write long arithmetics in c++ quick and bugless (and reasonably fast algos), then you are free to go and AC this problem in c++ =)

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

Why can't I see test cases?!

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

test 12 in A?

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

Can anybody share there approach to the problem I ??

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

problem k : wa on test 5 ? i dont know what did i miss ? can anyone help ?

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

i think its better to add the time limit to the statement for each problem.

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

When can we see the test cases ?

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

test 3 in E?

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

Can anyone tell me how this solution for G is wrong ? Code

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

    You are only looking at pairs (i, 2 * i).

    I'm guessing that you looked at and thought that there exists a pair with (i, 2 * i) by Pigeonhole or something.

    However, just look at n = 5, k = 3 and 1, 4, 5.

    To solve the problem, you have to look for every (i, x * i) which takes

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

Can anyone give me ideas for solution of A or C?

In A, can you modify convex hull and do it?

In C, the graph should have a Hamiltonian cycle, that's all I could think of. How to add minimum edges to make it happen, I have no idea

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

In the light of the upcoming ACM contest I looked into the last year Moscow quarterfinal problems: http://codeforces.net/gym/100792

I wanted to peek at solutions of some problems, but I didn't find any editorials or sourcecodes. Here on cf sourcecodes and tests are also not shown. So I have two questions:

  1. Does anybody know where to find editorial/outlines for solution/sourecodes of someone's solutions?

  2. If no, am I allowed to write and publish the editorial myself (at least partially), or is it forbidden for some reasons?

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

    I think it's okay to create a blog where everyone contributes to make an editorial. They will not link it to the contest, but as a discussion, I think it's alright

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

Regarding problem H (The Fence), there is a missing test case that makes some solutions fail due to exceeding the time limit. I think you should add it and rejudge all solutions.

The test case can be generated by this C++ code:

#include <iostream>
using namespace std;
int main() {
  cout << 2 << endl;
  for (int i = 0; i < 50000; ++i)
    cout << "10";
  cout << endl;
}
»
8 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Is there any official outlines for this contest? can't find them anywhere

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

Problem F was one of the least solved problems in the contest. I wonder why nobody has asked for a solution/hint yet. So let me do the honors. The statement is amazingly simple, but I haven't been able to make any headway on this. Any ideas in the right direction would be appreciated. :-)

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

How to solve K?

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

Someone please post their approach to problem K- Parquet ?