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

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

Всем привет!

31 июля 2017 в 17:35 (по московскому времени) состоится рейтинговый Codeforces Round #427 для участников из второго дивизиона. Как всегда, участники из первого дивизиона смогут принять участие вне конкурса.

Задачи для этого раунда были подготовлены мною. Большое спасибо Алексею Илюхову (Livace) за помощь в подготовке раунда и прорешивание задач, AmirReza PoorAkhavan (Arpa) за вычитывание условий и прорешивание задач, Александру Гаеву (krock21) за прорешивание задач, Николаю Калинину (KAN) за координацию раунда и, конечно, Михаилу Мирзаянову (MikeMirzayanov) за замечательные платформы Codeforces и Polygon.

Раунд будет длиться 2 часа, и вам будет предложено 6 задач. Рекомендую прочитать условия всех задач. Надеюсь, каждый найдёт интересную для себя задачу!

Разбалловка будет объявлена перед началом раунда.

Разбалловка: 500 — 750 — 1250 — 1500 — 2250 — 2250.

UPD.

Cпасибо за участие в раунде!

Разбор здесь.

Поздравления победителям!

Div2:

  1. ywwyww

  2. nick452

  3. JustAnAverageCoder123

  4. cxt

  5. wa1tz7I9

Div1:

  1. dotorya

  2. rajat1603

  3. anta

  4. Kaban-5

  5. HellKitsune

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

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

wow, already another round, i'm exited!

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

Damnit codeforces, two consecutive rounds is too much.

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

Hope short statements like your announcement :)

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

I missed previous round. I mustn't miss this round, wish everybody luck! :-))))

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

how can registration? please tell me

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

2 rounds in 2 days..amazing..

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

Two consecutive rounds.. in one time, when some people just are not able to take part — they are sleeping, including me :(

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

2 rounds in 2 days?

sign me the FUCK up good shit go౦ԁ sHit thats some good shit right there right there if i do ƽaү so my selfi say so thats what im talking about right there right there (chorus: ʳᶦᵍʰᵗ ᵗʰᵉʳᵉ) mMMMMᎷМ НO0ОଠOOOOOОଠଠOoooᵒᵒᵒᵒᵒᵒᵒᵒᵒ Good shit

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

Can't register. Says I'm already registered for the contest. Can someone help?

EDIT: Fixed now.

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

Will the problem statements as short as this announcement? :)

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

wow double div2 rounds! Brilliant!

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

Whom About this round ?

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

3 day after today will be another contest so we should say : one week ,3 contest,what a beautiful week!!!!

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

    There should be a coding weak every few months or so...where we get a competition each day of the week!

    (Or will it be too much? )

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

      <<There should be a coding weak every few months or so...where we get a competition each day of the week!>> that will be amazing ^_^ <<(Or will it be too much? )>> are you serious????

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

        Well it would be t000000000 much for the people like that guy above with 84 downvotes who said "Damnit codeforces, two consecutive rounds is too much."

        T00 much? lmfao!

        I'll tell you guys what too much is, too much is the gap between these competition,thats what too much is! LOL :P

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

WOOOWW so good that 2 contests in 2 days

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

I hope electricity will be fixed till the beggining of the contest :D

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

Wow. i like everyday have codeforces round!

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

Wow, I like have a codeforces round everyday.

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

nice

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

Wrong tag 417! Please edit.

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

is it going to be rated?

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

i wish next round like this start tomarrow :)

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

I had one question. is it rat

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

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

Not able to submit even though I'm registered.Anyone facing the same problem?

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

Problem in submitting soln to second problem, second question is not accepting submission , i m trying to submit but it does'nt resdirect to submission page and keeps loading , plzz look into this matter

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

Too difficult C these days .

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

some guy just opened an account and solved all 6 problems .... (I think this is a hattrick if memory serves me right) -_-

At this rate, there will be fewer div2 coders than div1 coders

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

Answering questions in this round was like.

We're sorry if the statements was not as clear as we thought

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

    Haha, sould've just written that in the statement.

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

    30 minutes spent after i came up with that. It is illogical to have 2 stars on a grid at the same position (and how can he see two starts at the same point?) so it was better to write it in the statement. (Me personally got the point when i realised that number of stars could be up to 10^5 and grid has 10^4 cells)

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

    Usually in this type of statements, I see that the phrase "All thingys have distinct co-ordinates" is given in such cases. Like in problem F, you are told that there is no road that connects a city to itself. So if you see no such statement, you usually take the worst case interpretation. So from my point of view, I don't think there was anything wrong with the statement

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

how to solve C ?

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

    prefix sums

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

    I (hope I) solved it with 11 2-dimensional Fenwick trees.

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

      Super overkill, dude...

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

        Yes...I realized that after the contest. Since the brightness of the stars is fixed for given moment, then we don't need the Fenwick tree at all. Still, my solution passed the system test, but I agree there's a cooler approach. :)

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

      I did the same :)

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

      Can you explain that solution? I solved it using dp.

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

        Let's for a moment assume that time stops and brightness of the start doesn't change at all. How could we then calculate the total brightness for a given rectangle? A 2-dimensional Fenwick tree does this in O(log100 * log100) per query.

        However, stars' brightness change in time over time. It's easy to notice their brightness state is cyclic and after c + 1 seconds it goes back to the initial state. Since c is quite small (up to 10), we can maintain c + 1 Fenwick trees for each remainder of t % (c + 1).

        Note that even though this works, as szawinis mentioned, this approach is quite an overkill and calculating the 2D prefix sum is much less verbose and easy approach.

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

    For every initial s calculate 2d prefix sums of stars so we can answer queries in O(c), because for each initial star brightness we know how many were there in the given rectangle and we can easily calculate what will be the brightness at the given time for this particular brightness.

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

      How exactly to sum more than one star in O(c)? Please explain a bit for me, thanks

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

        I don't totally know mraron's solution, but here's mine (got AC on sys test):

        Check every star, for every t (it is 0-c, so from 0 to 10), add it to the star's coordinate's and store the sums for a given time and given coordinates in a 3d array [t][x][y] (it's [11][101][101]).

        After you have the sum for every coordinate and every t, you can calculate 2d prefix sums for the table ([101][101]) and after that you can answer every query in O(1).

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

          I see, I oversight to generate all possible t [0,10], my function to sum it is just plain wrong answer, and TLE. Thanks!

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

      How do you calculate a 2D prefix in less than O(n2) time?

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

        We can calculate 2d prefix sums of array x × y in O(xy) in this problem x and y are the order of 100.

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

          Aha. So do I take it that if the bounds on x_i, y_i where higher, this approach wouldn't work? The method I thought of was O(qlogn). Sort the points by x then y coordinates and binary search on them and use a 1D prefix sum to calculate their sum. Then you can easily get their updated brightness after t_i time. does this work?

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

            Yeah because the overall complexity is O(cxy). I don't understand your solution yet, how do you exclude the points with bad y coordinates?

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

    Apparently a O(n + xc(y + q)) solution passes (here x = y = 100) with a sufficiently fast language. First, keep an array of all coordinate and brightness possibilities; put each star into its appropriate array. Now, compute the prefix sums of each row/brightness combination. Given this, we can answer each query in O(yc) time: iterate over all row/brightness combinations and find the number of stars in that row with the specified brightness that is also inside the query (can be done in O(1) because you have prefix sums). I'm sure you can fill in the rest of the details.

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

Nice pretests xD

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

How to solve D?

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

    I tried hashing but it failed on test case 5 are there anti hash cases in pretest

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

      mine gets tl and mle

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

      Mine failed pretest 5 too with hashing

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

      How can you hash when the string can contain not only letter characters?

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

        It does: The first line contains the string s (1 ≤ |s| ≤ 5000) consisting of lowercase English letters.

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

          OMG WHY COULDN'T SEE IT MAN =(. Btw what is your MOD number?

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

            It's always good practice to double-hash, so the two primes were 31, 37 and mods were the usual (1e9)+7 and (1e9)+9.

            I think pretest 5 is not an anti-hash test, since with double hashing, the chances of ever getting a collision are so low, it's nearly impossible. So, we can conclude that our algorithms were wrong :)

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

      Try using 2 hashes

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

      I used hashing with unsigned long long int. I was getting WA on pretest 5, but the error was with the greater K I was testing

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

    I tried to do so: DP[i][j][k]=DP[i][i+sz-1][k-1] && DP[j-sz+1][j][k-1] && leftside = rightside. When i figured out what my function for leftside==rightside is not right :( I think it is O(n^2log^2n)?

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

      I think what leftside==rightside(i, j, k) can be done with binary search :S Mine failed, i made it like it was (i, j, log_2(j-i)+1)

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

    Find values till logn. After that answer will be zero. Complexity n*n*logn

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

    I did something like this: you first have is_pal[i][j] = the substring from i to j is a palindrome. (is_pal[i][j] = 1 if is_pal[i + 1][j -1] = 1 and string[i] = string[j]) Now, notice that a K-pal is also a K-1 pal. So we need the maximum "degree" of a substring: 0 if it isn't a pal, 1 is it is a 1-pal, k if it is a K-pal. We will have dp[i][j] = the degree of substr from i to j. When we reach [i][j], we have to analyse its 2 halves and if [i][j] is a pal. Now notice that if [i][j] is a k > 1 pal, then it is a pal and its halves are also pals (so they are equal). If that is the case: dp[i][j] = dp[one half] + 1. Now add them to your answer. (Hope this will pass EDIT: it did pass )

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

    For simplicity, put a | between each character, as well as at the front and the back of the string. Now all palindromes will have odd length (possibly centered at a |). A radius of a palindrome is half its length, rounded down. (For example, the radius of abcdcba is 3.)

    First, find longest palindrome centered on each character. Naive O(n2) search is fine.

    Now, we will compute , being the largest level of the palindrome centered at m with radius r, minus one. , since a single character is a 1-palindrome. To compute , let r' = ⌊ r / 2⌋. If the longest palindrome centered at m has radius less than r, then . Otherwise, will be equal to , and you can set . Why it works is left for the reader, or I'll explain later.

    Now that you have your , we can prove that ai is equal to the number of that is greater than or equal to i. We can find all ai's in O(n2) time.

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

    I used suffix arrays to be able to check in O(1) if a sequence is a palindrome. Then I just checked each sequence to see if it is a palindrome. If it is, I check whether half my sequence is a palindrome and so on. Total O(N*N*logN) it fit in 1.3 secs.

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

    Basic insights. Every k-palindrome would be a palindrome, can be easily proved using induction. Every k-palindrome would also be a (k - 1)-palindrome.

    So, we only need to find max k for every palindromic substring of S, such that it is a k-palindrome.

    Here's what I did.

    1. Generate prefix and suffix hashes for S, let them be HP and HS.
    2. Iterate over all substrings. For substring S[i][j], check if HP[i][j] = HS[i][j], i.e. if prefix and suffix hashes are same only then the substring would be palindrome.
    3. If S[i][j] is palindrome, recursively do the following.
    4. If len(S[i][j]) = 1, return 1. (strings of length 1 are 1-palindrome)
    5. Else L and R be left-half and right-half of the strings, as defined in the question. Check if hash(L) = hash(R), i.e. check
    6. If hash(L) ≠ hash(R), return 1. (given string is just a palindrome)
    7. If hash(L) = hash(R) then do step 3 for L, and return ans(L) + 1

    Now, this solution wasn't passing under time-limit, so to optimize I used an unordered_map to store answer for all palindromic substring hashes that I've seen and if I see the same hash for any substring again, I just lookup answer for it in the map.

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

Very nice problems! Thanks, qoo2p5!

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

Short announcement, short statements. Cool!

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

    yup, looking at his submission, he just change a comment to intentionally get hacked. Though, we cant be sure if the hacker co-operated with him.

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

HELP! Somebody help me with B. I didnt passed the pretest. Though it passed all tests i made my as per my intution on my pc. i dunno what i missed.

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

Thx for the short statements!

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

how to write a proper generator to cause TLE on B. I keep getting Generator crashed. I tried print(1e8) loop 1..1e8 : print('8')

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

Does O(N2log(N)) pass for D ?

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

anyone has any idea about the third pretest for C ??

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

Any hack tcs for div2 A,B? Thanks!

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

How to solve E ???

PS: E was a very awesome problem.

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

    I have an idea asking for each of bit of the position but dont have enough time to code

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

    Let answer be A and B (A<B). For each bit position, find whether the bits at that position are same or different in A and B. For highest diff position, A has 0 and B has 1. For all other positions, find the bit at that position in A. Correspondingly, you get the bit for B.

    To check if the bits at position pos are same/different for A and B, put all numbers having 0 at position pos in a set and query the system. If the number of occurrences of Y is 1, then the bits at pos are different in A and B.

    To find the bit at position pos for A (after you've found the highest differing bit high), put all numbers with high=0 and pos=0 in a set and count the number of Ys in it. If the number of Ys is odd, then A has 0 at position pos and 1 otherwise. Now based on the relation found earlier (bits at position pos are same/diff for A and B), you know the bit for B too.

    To count the number of Ys in a set, use the following -
    If size of set is even, the no of Ys is 0/2 if XOR is 0 and 1 if XOR is X^Y.
    If size of set is odd, the no of Ys is 0/2 if XOR is X and 1 if XOR is Y.

    You can see my code for an implementation of the same.

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

    I was asking for each bit. Then answer for some bit must be y or x xor y and then I have numbers which have only one y. For first number I just make binary search on numbers with this bit.

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

    For simplicity, suppose there are 1024 icicles numbered from 0 to 1023, so you can interpret them as 10-bit bitstrings.

    First 10 questions: ask the icicles that has 0 on i-th position, for each i. If there are 0 or 2 of the special icicles, the XOR will be 0; otherwise, the XOR will be x^y. Also note that it's impossible for all questions to give XOR 0.

    Now you know the answers to the questions. Suppose the special icicles are numbered p, q, and their XOR is r. We claim that the i-th bit of r is 1 if the i-th question gave x^y, otherwise it's 0. It's actually not difficult to prove; you can try it, or I'll expand on it later.

    Now you know that there are 512 possibilities of pairs of the special icicles. Interestingly, each icicle is involved in exactly one of them. Pick one icicle from each pair arbitrarily, then binary search on them.

    EDIT: Since n is not necessarily 1024 (it's impossible to be that, in fact), you need to fudge with it a little. You're still asking the same question, but now the response is either 0 or x^y (if there are an even number of icicles), or either x or y (if there are an odd number of icicles).

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

    Let set Ai be the numbers from 1 to n that have their ith bit on. Also let F(H) function be the xorsum of set H's elements. If for some set X or then X contains only one special element. We'll calculate F(Ai) for every 0 ≤ i < 10 (this is 10 operation). Let j be the first set Aj that Aj contains a special thing. Let's do binary search in 9 steps to find it (we can do it because |Aj| < 512). So we have the index of one special thing, but remember the 10 steps we did earlier? Just invert those bits in this one to find the other special thing.

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

Can someone please explain problem D in detail!!

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

    First of all, observe that there can be no k-palindromes such that 2k > n / 2.

    Let's calculate dp[k][l][r] which denotes whether [l..r] is a k-palindrome (i prefer something like bitset < N > dp[K][N]).

    The basic case is k = 1. This can be obtained in O(n2) if we just launch from all possible middles of palindromes.

    For k > 1 and [l..r] we just have to check several things (assuming m is the median of this segment): whether s[l..m] = s[m + 1..r] and whether dp[k - 1][l][m] and dp[k - 1][m + 1][r] are (k - 1)-palindromes (depends of parity, but the main idea remains the same). Hence you get .

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

      if [l..r] is K palindrome , then its also K - 1 palindrome , hence you can get complexity down to N2.

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

        Oh, nice observation. Didn't even think this way :)

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

        How? Even then, there are N^2 log(n) states. Then how can you bring down the complexity to N^2?

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

          Instead of using state DP(L, R, K) denoting whether str[L..R] is a K-palindrome, use the state DP(L, R) which stores the max K such that str[L...R] is a K-palindrome.

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

            Can you please explain a little bit more about it. How can we find whether a number is k palindrome or the max K such that the particular substring is palindrome without checking whether it's a k-1 palindrome or not?

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

              I used 2 DPs. A string is K-palindrome if it is itself a palindrome and its first half is (K-1)-palindrome. Non-palindromic strings are 0-palindromes.

              is_palin(L, R) returns true if str[L,R] is palindrome.

              DP(L, R) returns largest K such that str[L,R] is K-palindrome. To find K, I first check if str[L,R] is palindrome itself or not and then use the relation DP(L,R) = DP(L,MID) + 1, where MID is the end of the first half of the string.

              See my code.

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

      I wonder why my n log n solution got TL.. I'll be very lucky if you helped me. :) 29077577

      Is it all about bitset?

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

      How can you know s[l..m]=s[m+1..r] without hashing? and also can you explain a good hashing function?

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

        Calculate lcs[i][j] — the length of largest common substring of indexes i and j.

        It can be easily seen than lcs[i][j] is lcs[i + 1][j + 1] if s[i] = s[j] and 0 otherwise. So you compute this in O(n2).

        How can I know now? I have to check whether s[l][m + 1] is greater or equal than m - l + 1.

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

    My solution for D is pretty straightforward I think, let me know if something is not easily understandable from my code.

    http://codeforces.com/contest/835/submission/29067296

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

It's really scared that In problem D I came out with a very complex idea( to me :) ),which make me code for more than an hour T^T,Hope it pass...

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

Waiting for round #428 ...

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

-- Как всегда, участники из первого дивизиона смогут принять участие вне конкурса. -- Кажется, участникам первого дивизиона не интересно участвовать ВНЕ конкурса :)

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

I finished problem C, but I have not submitted. T^T

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

I'm curious did anybody manage to get AC on D with O(n^2logn)? My O(n^2logn) solution was about as optimized as it could be (super low constant) but got TLE.

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

This was a really nice and smooth contest, good problems, short statements and good pretests. Thanks to everyone involved for making this such a great contest.

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

I literally spent the whole contest trying to solve C but I kept getting WA on pretest 3
Here's one of my submissions 29072095

I'd be glad if someone tells me what I'm doing wrong, it really drove me nuts throughout the entire contest.

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

    try this case:

    2 1 2 1 1 1 1 1 2 0 1 1 1 1

    answer should be 3

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

      I was doing such a stupid mistake by iterating over the input multiple times in case of coincided coordinates, handled it, and ur test passes now, still WA on test 3 though.

      New submission 29076795

      Appreciate ur help.

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

    Most people messed up because they didn't realize two stars could be at the same point. I didn't look at the code but perhaps that helps?

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

The test case for problem C were very weak. Brute force solution is getting AC verdict.

See this code

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

В задаче С, мне кажется, следовало бы добавить пояснение о том, что в одной клетке могут быть несколько звезд.

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

how to solve problem — C?

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

    hint: use partial sum

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

    i have the same problem as your submitted code, but i solve it, the second operand of % should be on c+1 not c !

    because the original problem tells us s<=c and if s>c the variable s have to be equal to zero, so the range of numbers that s can have is 0,1,2,...,c

    After that you will face with TLE :D

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

Any discussions on the last problem? How do people write such long codes in such short time.

I cannot even write codes for C without bugs.

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

Test cases in Div 2 C problem are very weak. Even brute force of O(Q*10^4) is getting AC :(

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

test cases for problem C were very weak.even O(q*n*n)(n=100) solution got AC. see this solution i think it should be rejudged with proper test cases.

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

    I think there is maxtest in system tests, and I think judge can do 10^9 simple operations in 2 seconds.

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

    Yeah its not fair!, The problem should be rejudged with proper test cases.

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

    Yes, it's my fault, but the test cases are not weak. Codeforces invokers are quite fast, so 10 ^ 9 simple operations passes in 1.5 seconds.

    I tried to make the contraints not too strict, but it happened that they were too small.

    But, as I can see, the problem hasn't affected many participants, so everything is alright.

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

By the way, I would like to thank qoo2p5 for the absence of anti-hash tests for problem D :) This really makes me happy (although I should have calculated lcs in O(n2) time :D).

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

Because of one symbol, I got WA. I erased this symbol after contest and got AC. I'm so sad...

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

how to hack in contest

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

Could someone help with this one ? O.o Problem B submission I can't figure out why it should get WA on 24 :/

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

    nevermind, I am a dumbass ._. found the silly mistake in line 179

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

    When, calculating req you want to take ceil((k - sum) / (9 - i)).

    int req = (moar + (9 - i))/(9 - i); should be

    int req = (moar + (9 - i - 1))/(9 - i); as in case (k - sum) % (9 - i) == 0, your req would be off by 1.

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

How to solve F?

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

Scrolling to find a comment about rating change? If yes, like this comment :P

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

regmsif is a cheater for sure. Templates of his submissions are completely different. KAN

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

    And he solved B and F almost at the same time.

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

      he is not cheater: http://blog.csdn.net/lych_cys/article/details/51326079 F was from before :)

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

        Templates of his solutions of other tasks are still different.

        Timestamps of your submissions also seem suspicious to me, by the way.

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

          Why couldn't i write codes in different styles? i used to use one of the styles, and recently i'm trying to change to another one (you'll find it if you check my submissions before). These styles are both good and bad, one of them seems more beautiful, while another one seems shorter, and can be typed quicker. i don't mean to cheat.

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

        I won't say he is a cheater for sure, but it doesn't explain the difference in tab width, and the small difference in submission time. and also there's quite some small difference in style like the use of class and line spacing etc..

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

Is the educational round unrated? Or somebody just forgot to update the ratings.

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

In problem C, Is it possible that two stars are at same position?

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

    Yes it is, knowing that there can be up to 10^5 stars and there are at most 100^2=10^4 pionts on the plane it's pretty clear that there will be some overlaping stars.

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

      So for example if there are 2 stars at same place ( brightness 2 and 3, c=4). after 1 moment it's brightness will be 3 and 4(total = 7) ???

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

Is it rated? Looks like not...

Or somebody just forgot to update the ratings.

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

Can someone explain why is't publish the final result of contest?!

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

KAN qoo2p5 Please check Ali.P and Ali.PI submissions, seems same thing to me, possible cheat. Ali.PI Submission , Ali.P Submission

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

Ratings rolled back? weird. Edit: They are back with new ratings. Apparently mine increased. wtf?

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

What's wrong with the rating changes in this contest? My new rating disappeared and so does many others (I checked)!!!

UPD: NOW BACK TO NORMAL.

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

How this one passed C — 29077578 :| Just looping from (x1, y1) to (x2, y2). Shouldn't that give TLE? As it is O(1e5 * 100 * 100) ~ O(1e9) in worst case!

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

My rating disappears and my submission is marked "skipped". What's wrong

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

    Your's C: 29067352
    jt3698's C: 29073459
    Your D: 29073399
    delete4's D: 29073330

    Only variable names differ! Notorious Coincidence or what?
    CF usually forgives cheating for first time and second time bans both account :)

    I think you also cheated in A & B. And used ~4 accounts, and one of those accounts also got outside of contest [I wonder why other's solution didn't get skipped -_- ].

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

      Both of the submission you put are significantly later than mine. And you can check the codes are in agreement with my coding style.

      If you I am considered cheating because I leaked my solution on ideone. Fine. But why is jt3698 and delete4 still in the competition?

      And please clarify the reason you think I "also cheated in A&B"

      After a closer inspection, I think jt3698's code is very different from mine. You should think more carefully before accusing other people.

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

      Thank you for sending me the links, though.

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

Actually the problem F is quite similar to one problem in NOI(China)2013 . So if I have solved that problem before and I copied the code so I finished the problem very fast(only in less tha 5 min, for example ) , is that cheating?(Actually this time I wrote the code again)

Sorry for my poor English.

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

The same solution for problem C using C++ got accepted link

but got TLE using C# during the contest Link

And I see many solutions like this.

very nice...

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

I tried to solve E using binary search, where first i'm finding index such that xor of indices 1 to index contains exactly one y. Then using binary search between [1,index] and [index+1, n] i'm finding indices of y. But due to redundant queries i'm not getting right answer for n > 500. Can someone optimize it or tell why is it not possible to solve using binary search. Here's my code http://codeforces.com/contest/835/submission/29088791. Thanks in advance

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

    It is not possible to find using binary search the first Y in a sequence which has 2 Ys, because the prefix XOR function is not monotonous.
    eg. Let the sequence be str[] = XXXYXXXYXXX (1-indexed)
    The prefix XOR of str[1..2] is 0, of str[1..4] is X^Y and that of str[1..8] is also 0.

    What do you do when you encounter a prefix XOR having value 0? Do you go left or right? In case of str[1..2], you need to go right. But in case of str[1..8], you need to go left. The prefix XOR values are NOT monotonous.

    The algorithm you mentioned will work if the sequence has only 1 Y.

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

      Let's say mid = (1+n)/2, now if 1 to mid values don't contain only one y i.e(value is not y or x^y) then we take mid1 = (1+mid)/2 and mid2 = (mid+n)/2, now we keep doing mid1 = (1+mid1)/2 and mid2 = (mid2+n)/2 until one of these mid values don't contain exactly one y. Then we assign values as i mentioned before i.e start1 = 1, end1 = mid(or mid1 or mid2), start2 = end1+1, end2 = n and proceed as before. If something's wrong here, please correct me.

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

I don't know why DIV.2 problem C is NA... 29145513

BUT!!! This code is accept.. 29145520

It's just different this code

for (int t = 0;t <= 10;t++) { sum_val_map[t][y][x] = ((c + t) % (C + 1)); (NOT ACCEPTH)

for (int t = 0;t <= 10;t++) sum_val_map[t][y][x] += ((c + t) % (C + 1)); (ACCEPT)

Somebody explain it to me plz!!

Do duplicates come in as inputs?