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

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

Привет!

1 июня (пятница) в 17:35 (Московское время) начнётся Codeforces Round 486 (Div. 3) — третий в истории Codeforces раунд для третьего дивизиона. В этом раунде будет 6 задач, которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Наверное, участникам из первого дивизиона они будут совсем не интересны, а для 1600-1899 покажутся простыми. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса.

Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов. Я постарался сделать приличные тесты — так же как и вы буду расстроен, если у многих попадают решения после окончания контеста.

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

  • принять участие не менее чем в двух рейтинговых раундах (и решить в каждом из них хотя бы одну задачу),
  • не иметь в рейтинге точку 1900 или выше.

Независимо от того являетесь вы достоверными участниками третьего дивизиона или нет, если ваш рейтинг менее 1600, то раунд для вас будет рейтинговым.

Спасибо MikeMirzayanov за платформы, помощь с идеями для задач и координацию моей работы. Спасибо Максиму Neon Мещерякову и Ивану BledDest Андросову за тестирование раунда.

UPD: Также хочу поблагодарить step_by_step и eddy1021 за тестирование раунда и помощь в его подготовке!

UPD2: Вам будет предложено 6 задач и 2 часа на их решение.

UPD3: Опубликован разбор задач. Спасибо Михаилу awoo Пикляеву за помощь с переводом.

UPD4:

Поздравляем победителей (официальные результаты):

Rank Competitor Problems Solved Penalty
1 volamtruyenkyii 6 196
2 IOI2018 6 238
3 Student_of_Husayn 6 303
4 fshp971_ 6 311
5 Deadpool 6 313
6 Jajceslav 6 341

Поздравляем лучших взломщиков:

Rank Competitor Hack Count
1 jhonber 70:-1
2 djm03178 61:-4
3 applese 53:-1
4 Midoriya095 41:-3
5 step_by_step 38:-5
6 greencis 57:-45

Было сделано 530 успешных взломов и 401 неудачный взлом!

И, наконец, поздравляем людей, отправивших первое полное решение по задаче:

Problem Competitor Penalty
A Uzumaki_Narutoo 0:02
B Ad1let 0:06
C Ad1let 0:12
D volamtruyenkyii 0:23
E fafafa 0:19
F MuieEcaterina 0:49

Надеюсь, что задачи вам понравятся. Если вдруг что-то не так окажется со сложностью задач, то будем подстраиваться в следующих Div.3 раундах.

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

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

It will be the second Div.3 round in the history of Codeforces.

Actually, this is third Div.3 after rounds #479 and #481.

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

Finally, Div.3 round :D

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


Can someone to hack CF rating?? +100 for successful hack. -50 for unsuccessful hack. Just reduce my rating by 1 point. 1600 -> 1599. Because my rating >=1600. So it is unrated for me. But I still want to participate.

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

If suddenly something does poorly with difficulties of the problems,

The grammar here is poor. I'm not quite sure what this is trying to convey, but perhaps

If the difficulties of the problems in this round are poor,

or even

If the problems in this round are too easy or too hard,

would be better.

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

    Thank you for correction, it's fixed now

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

    In fact, I think the difficulties were just about right, nice to have a bit more of a difficulty gradient than what we've seen before

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

Div.3 ! Round for Newbies like me :)

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

"if your rating is less than 1600, then the round will be rated for you."

+respect

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

can anyone explain the difference betwwen div2 and div3.Thank you.

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

    div 2 is rated for > 1600 and the problem is pretty hard and not too easy and for div 3 is rated for under 1600 and the problem pretty easy not too hard (you can check the past contest and learn from it)

    for full explanation -> http://codeforces.com/blog/entry/59228 Meow !

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

    Div 2 Rated for -infinity < Rating < 2100.

    Div 3 Rated for -inifity < Rating <1600

    Div 2 got some problems easy, some medium and some hard.

    But to help improve the newbies and others learn, CF invented Div3.

    Div 3 will contains majorly problems of easy and few medium difficulty.

    High Ratings to EveryOne !!

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

so excited <3 to be Expert, it is just 144 :/

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

Hope to be green lol.

it's just 6 points

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

If i never join the contest (unrated account), will this contest rated for me?

**I'm sorry for my poor english & question

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

Scoring?

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

Suited for me....

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

?detaR tI sI

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

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

Hope that I will become expert after this round. :)

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

    you won't i bet

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

      Let me talk to you after the contest.

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

      Bro you was saying something :)

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

        It might look like I was rude and unprofessional but I did this just to make you really serious for this contest so it goes very nice for you. I commented the same on some other person also, so to give them huge confidence boost. Looks like it worked for you. Good luck for future contest also.

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

Хорошо быть серым) Советую

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

Wow!! Already 8k. Gonna be challenging.

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

Is it Div.3 contest if only 3 contestants with rank below 1600 (out of thousands) have solved E and F in first hour??

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

    "If the problems in this round are too easy or too hard, then we will adjust the difficulties in the next Div. 3 rounds."

    Also I think that's good. It differentiates contestants more, than everyone solving ABCDEF and rating only by solve times.

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

Who thinks that 20 points of penalty are too much?

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

    That's standard ACM rules. I think it's fine because it encourages people to write correct code rather than fast code :)

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

Is it just me or somebody else noticed the mistake in question D!!??

in the output format they have said

"In the second line print m integers — the coordinates of points in the subset you have chosen."

but actually you have to print the numbers itself!! XD

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

    Well the numbers you print represent the coordinates

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

      many times they ask us to print the index so it kind of became confusing!

      and again i just asked does anyone else feel the same, just wanted to know how others think! Though no offense to the setters the problem was good!!

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

        Yes, they do mostly ask for the index, I agree. I didn't mean to offend you or something ;)

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

Seemed more like a div2 contest than a div3

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

How to solve " Divisibility by 25 " ?

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

    find lastest 0, 2, 5, 7 in given integer. then we know how many swaps we need to make 00, 25, 50, 75 at the end of integer.

    but, you have to consider 0 being at the frontmost number of integer, which is a point i made a mistake.

    For example, if we are considering how many swaps we need to make 25 at the end of integer, and if 2 is the frontmost number of integer (before swapping), and if k 0s continue behind 2, (i mean, 200000235234 has five 0s behind 2, k=5), you need to swap k times more. So you can just add k at the answer.

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

      As you said that we only have to deal with the last set of 00,25,50,75 so for the given example we dont have to go for swapping the 0's.We can use the 2 in the 3rd last position and 5 in the 4th last position to get ans=5.I dont understand when will we ever face the problem of getting 0 as the leading digit?

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

    Solution for E: for each case of 00, 25, 50, 75: find the last digit of the case (_0 or _5) in the given string at the rightmost position and swap it to the end (ans += swap distance), then find the second last digit of the case (0_, 2_, 5_ or 7_) in the string at the rightmost position and swap it to the second-last position (ans += swap dist). Then try to swap starting zeroes (if any) with a non-zero digit (which must be at least third-last) (again: ans += swap distance). If the final string is a correct number then consider the 'ans' as a candidate for the shortest answer. Solution with regexes, Perl: 38862670.

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

great balance imo

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

How to solve D? m is less or equal 3, isn't it?

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

    Yup, but I kept getting WA

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

    Yup, the maximum size of subset is either 1, 2 or 3 :)

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

      why cant the max size be more than 3

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

        Because 2a + 2b = 2c has a = b and c = a + 1 as the only integral solutions. Now, If u have 4 numbers then the distance between 1st and 4th will be 3 * 2a which is not a perfect power of 2.

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

    Feels bad when you figure it out right after the contest (:

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

    There are only 3 possible options:

    1) Just choose any one to get a set of size 1.

    2) Just choose any pair such that S = {x, x + 2d} for some x in the array, and some d such that x + 2d belongs to the array. It works trivially.

    3) Choose, if possible, for any element x in the array, the set S = {x, x + 2d, x + 2d + 1} since it's the only choice to maximize the size (It's not possible to add another one with difference 2^{d+2} since 2^{d+2}-2^{d} is a multiple of 3 and also consider that it also shows that is not optimal to choose different d's as pairwise difference), remember that all those elements need to be in the array.

    One can get all the information needed by mapping values to indices and just checking for a not null index in each try. Woof!

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

Enters Div2 rounds.. Solves A, B & C...

Enters Div3 round.. Solves only A, B...

What ??

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

Was it really a div3 round? Cuz it looked like a div2.

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

How is this possible that i have TLE when my algorithm calculates in O(n * 30) ?

38858406

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

Yes, we know about fast solution to the problem F (with Li-Chao tree). But in hard version this problem is too complicated even for the last problem of the div3 contest. This why we prepared this problem with such constraints.

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

    I thought it was simple dp?

    I mean just dp without using any others data structures

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

      Yeah, dp solution have O(n^2) time complexity and this is accepted. But there are exists some other solution with dp and convex hull trick (also known as Li-Chao tree) which have time complexity O(n * log^2 n).

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

Can anyone say why did I get runtime in this code Problem B (Test 7)? Code
I had made 10 submission to get it accepted, which resulted in huge penalty...

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

If the problems in this round are too easy or too hard, then we will adjust the difficulties in the next Div. 3 rounds. Again, in the next round :(

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

Will greedy strategy work for 988E - Divisibility by 25?

I mean a number is divisible by 25 if only it ends with 00, 25, 50, 75. So from the end we search for last digit (i.e. 5 of 7**5**) and then for second last digit. If at last there are leading zeros then we make the first non-leading zero number as first.

I got WA on test 23, but I feel I missed corner case!

UPD: Yes, it was a corner case :'(

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

    23 was the first one with a 2 digit input (I was using python and got a runtime error when checking for the leading 0 afterwards).

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

How to prove that in the problem D: 1 <= m <= 3 ???

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

    Assume x < y < z satisfy that y - x = 2a, z - y = 2b and z - x = 2c. Then 2a + 2b = 2c. Notice that c > max(a, b), so 2max(a, b) divides 2c, and therefore it divides 2a + 2b, so it must also divide 2min(a, b), implying that a = b.

    Then any three number subset satisfying the condition is an arithmetic progression. Therefore if w < x < y < z have all differences powers of two they must all be in arithmetic progression. This is impossible because then z - w = 3(x - w) and z - w isn't a power of two as it's divisible by 3.

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

    assume there are four integers a<b<c<d satisfying the condition. let b-a=2^k, c-b=2^l.

    c-a=2^k + 2^l must be a power of two, thus k=l.

    c-b=2^k.

    similary, d-c=2^k

    then, d-a=3*2^k, must be a power of two, but is not.

    So, 1<=m<=3

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

    try proving with contradiction, what if n==4? (show that it cannot happen by using subtraction of bit pattern of numbers).

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

    Suppose we already have the sequence a[1],a[2],...,a[k]. It is clear that it must be (a[k]-a[k-1]) = (a[k-2] — a[k-3]) = ... = (a[2] — a[1]) = 2^d, d > 0. Try it on 3 numbers, suppose we have a sequence a1,a2,a3 and a2 — a1 = 2^a, a3 — a2 = 2^b, with a <= b. Then a3 — a1 = 2^a + 2^b = 2^(b-a) * (2^a + 1), which is a power of two only in case when a = b. So the sequence should be like k,k+2^d,k+2^d+2^d and so on. Consider an example now with four numbers in sequence, a1,a2,a3 and a4. (a2 — a1) = (a3 — a2) = (a4 — a3) = 2 ^ d Then a4 — a1 = 3*2^d which is not power of 2. The same goes for m > 4.

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

Missed problem E by just a minute. Contest was over just when I was about to submit problem E :(

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

Why test case 8 in problem E (50267) the answer is 5?

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

    50267 -> 52067 -> 25067 -> 20567 -> 20657 -> 20675

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

    Damnn I too kept getting WA there. I couldn't come up with a test cases like this. The point is in 50267, you want to get the 5 to the right .In doing so your intermediate number is 05267 which has a leading 0 and thus isn't accepted. You need to do another swap — (0,1) which will make all the intermediate numbers not have the leading 0.

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

Hmmm...

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

Contest of maps and sets

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

I could only do A, B, C and D. (Before system testing) And I think the difficulty of the questions are absolutely fine !

You end up learning more if there are two questions out of your reach, rather than just 1 or doing all of them. I definitely appreciate the difficulty of these problems. Please don't water it down for the next contest.

My only complaint here is that your previous contest had one question from every topic — DP, graphs, binary search, STL, number theory, etc ... Whereas the other two Div 2 contest didn't cover as many topics.

We got STL and I guess you could call D some kind of number theory where you observe the answer is never more than 3, but still we didn't get a pure number theory one like your previous D — Multiply by 3, Divide by 2 did ! There were no graph problems either.

In short, my feedback is this — The difficulties are great, pre-tests are great, Just add more topics :)

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

Why are there some guys hacking themselves? lol

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

A div3 contest with 3 div2 problems for me :(

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

In D, my mistake was printing a long long int instead of an int. Naturally, long long int wasn't needed. But is this a legitimate reason to give a WA?

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

    That's really strange..

    I used printf("%lld", ~) and get AC

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

    Well you not print any solution, look carefully~ Just try it to run locally

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

    That wasn't your mistake — it's just a slightly confusing error message. Your code outputs 0 for that test (as 42 isn't a power of 2) without a second line which causes the error message seen.

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

      You're right. Why was the correct output 1 42, when 42 isn't a power of 2? I can't have that in my subset right? Or can I?

      UPD: When the max size was 1, I printed any element. Just got AC. Why is this correct though?

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

please explain solution of C??

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

    While you reading the input get the sum of the numbers from the current array. Every time check if the current sum has been encountered before. Now traverse the array once more and map this value (sum — a[i]) with arrays index, and its position in the array. Check out the code: http://codeforces.com/contest/988/submission/38843860

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

    For each set if elements, first calculate sum of entire set. Then calculate difference matrix by subtracting each element from sum. Use a global map(common for all the sets) for hashing and storing indexes, and check whether each difference element was obtained earlier or not. If yes, you have found common sum producing elements in the 2 sets!

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

D --The size only can be 1,2,3 (but why?) Maybe the "conclusion promble" in div3 is a little bit weird?

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

    Let A = C + 2a, B = C + 2b, A ≥ B.

    According to the problem, A - B = 2a - 2b = 2x should hold.

    Divide each side by 2b. The equation would be 2a - b - 1 = 2x - b.

    1) If x - b = 0, then 2a - b - 1 = 1 -> 2a - b = 2 -> a - b = 1 -> a = b + 1

    2) If x - b ≠ 0, contradiction since left side is odd and right side is even.

    So there are at most 3 which is C, C + 2a, C + 2a + 1

    IMHO, this kind of problem is little challenging for div3 but worthy at the same time.

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

Couldn't debug the runtime error in my solution of B !. Someone help : 38838754 Problem B : RUNTIME ERROR ON TEST 7

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

    Try submitting it using the C++17 Diagnostic compiler, it might help in debugging.

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

    I had the exact same issue. The error is in the comparator.

    One of the requirements for a comparator is that

    If comp(a,b)==true then comp(b,a)==false

    One way to fix it is to return false if a == b before you check if a is in b.

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

    http://codeforces.com/blog/entry/59770?#comment-434966

    For your case,

    bool comp(string l, string r){
    	return l.length() < r.length();
    }
    
  • »
    »
    6 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    return l.length() <= r.length(); — is not right. return l.length() < r.length(); — is right.

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

      When both strings are of equal length, they must be exactly same, for this ques. So, it shouldn't matter whichever comes first. Can you explain why "=" should be removed.?

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

        Because If comp(a,b)==true then comp(b,a)==false is a requirement for the comparator.

        If two strings are of the same length, then comp(a, b) and comp(b, a) will both be true, which breaks the requirement.

        On the contrary if you remove "=", then comp(a, b) and comp(b, a) will both be false, which doesn't break the requirement.

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

Can someone tell me what's wrong with my code? 38862572 It is getting a runtime error in testcase 7 But when one of my friends submitted the same code from their account after the contest, they got it ACed I made it a point to compare both codes on an online text comparator and it gave both codes are same.

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

What is the complexity of ACd solution for problem D?

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

There are unrated peoplr in the official standing

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

Hi all, I am new to CF contests. I am not able to locate the hacking option on my dashboard. The 'hacks' tab also has no such option for me (it only shows hacking results involving other hackers and defenders). Can someone help me out with this? Thanks.

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

Unexpected verdicts again, hacks #456187 and #456189.

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

in problem E for sample case 1 :5071 i think answer should be 1:-
5071 to 1075

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

Test 27 of problem D is made to fail if unordered_set is used, why is that a thing?

EDIT: It fails with C++14 and passes with C++17, fuck me I guess.

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

thank you for very nice problem set. Had a really great time :)

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

Is problem E somehow related to Digit DP ??

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

    i dont know about dp solution but i think E can be solved without dp

    result is min(case25(), case50(), case75(), case00()). Here case25() is a simulation function that return minimum swap to make the last 2 digit is 25, if it cant make it, return infinity. If result is infinity print -1.

    however i'm getting WA because i didn't read the problem statement carefully "your number can't have leading zeroes"...

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

someone give me hack test for problem E. I want to know if my solution is correct .. thanks :)

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

I like the idea of harder D, and E(i really think they are harder than the last Ds and Es of Div. 3) so people who just know how to implement fast are ranked lower then the ones who are skilled at getting fast ideas for problems, but implement kinda slower, so those programmers can get rating a bit faster, but also because you don't finish the round in 1 hour. Super Cool problems nonetheless !

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

Why will this code return 0xC0000005(Index out of bound) instead of 0?

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

int n;
string ss[110];

bool cmp(string s1, string s2) {
    return s2.find(s1) != -1;
}

int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for(int i = 0; i < n; ++i)cin >> ss[i];
    sort(ss, ss + n, cmp);
    return 0;
}

The input data is as follows.

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

    I guess cmp was a bit not properly

    cmp should return whether s1 should be in front of s2 in the result array or not according to your sort rules.

    when a=b="aaa",cmp(a,b) and cmp(b,a) both be true.

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

      I don't think so. For example, in integers comparison, we use the cmp function:

      bool cmp(int a, int b){
          return a < b;
      }
      

      Even if a == b, and cmp(a, b) = cmp(b, a) = false, our program will return right result, isn't it?

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

        My fault.

        But when cmp(a,b)==cmp(b,a)==true, sort will TLE.

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

          Yes, you are right. So, I am confused to why that code will return 0xC0000005.

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

            Indeed,sort use so called quicksort when n>16

            while (true) {
                while (*__first < __pivot) // here always true
                    ++__first;
                --__last;
                while (__pivot < *__last) // here always true
                    --__last;
                if (!(__first < __last))
                    return __first;
                iter_swap(__first, __last);
                ++__first;
            }
            

            Your cmp may cause out of bounds, so when n>16 it will RE.

            UPD:use stable_sort instead?

            Chinese version:sort在n>16的时候用通常意义上的快速排序,对于a<b且b>a这种情况(非偏序集?),指针就跑飞了~

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

      I think that you are also a Chinese, how about we talk in Chinese?[斜眼笑.jpg]

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

is hacking phase will affect the standing result ?

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

    Yes,for only those who have their solutions hacked,going by the rules of educational rounds.But those who had successful hacks won't be affected.

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

Подозреваю эти участники переписали код

http://codeforces.com/contest/988/submission/38844693 http://codeforces.com/contest/988/submission/38848592

Ну очень совпадает код у них

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

Why does the contestants who are blue or higher have * marked before their name in status?

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

my rating has not been updated after div 3 why please help

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

I'm new to CF contests. Kindly help. Do the final standings that are currently displayed include hack scores too? (+100 for a successful hack and -50 for unsuccessful hack) How do I know if my solution has been hacked? Also, tentatively, by when will the ratings be updated?

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

    If your solution is hacked,you will be able to see it in your submissions.It is informed on the moment whenever your code goes hacked.

    The ratings update takes some time..But it is quite sure to be updated within an hour or two.

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

      You may want to use CF predictor extension in Google Chrome.It shows you an assumption of what your ratings increase or decrease will be.It has always given me perfect rating change.

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

    just In the Div2 and Div1 contests you can hack during the contest and get points ,and they show you a window that tells you if u have been hackd . In the educational competitions and div3, you can only hack after the contest is over and the hack results didnt affect your points. For the rating it may take from half an hour to 4 hours Or more to be update.

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

      But if someone's solution is hacked, his solution won't be counted as correct and he won't get full points for it right?

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

        right

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

          though if someone hacks successfully he won't get points for it? what is he hacks incorrectly? will he get negative points?

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

            It is supposed to be that way.Still, there is no update in the standings yet for the one who has attempted a hack.I think the score for the hacking attempts will be rejudged during final system tests.

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

Hi All, can anyone tell me why the subset size is at most 3 in problem D?

I got it from above comments. Thanks!

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

    Assume points a, b, c are in increasing order, and let d(x, y) be the distance between points x and y. if d(a,b) != d(b,c), they cannot be in the same subset because d(a,c) wouldn't be a power of two. So if a, b, c are in the same subset, d(a, b) must be equal to d(b, c).

    Now assume that you want to add another point x (x>c) in the subset. According to what I mentioned above, d(b,c)=d(c,x). But this means d(a,x)=3*d(c,x), which means it's not a power of two. So the subset size cannot be larger than 3.

    Edit: Good that you got it already!

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

Summary of hack for C (test 29): There were a lot of solutions that iterated over an O(K^2) loop. It passed original tests because when K is large enough, there tends to be a lot of YES answers and the solutions would just print it out right away when found.

The largest possible K with the answer NO we can easily think of is when K=20000 and ni=10 for each sequences, where every elements of each sequence are the same. But still some solutions passed through.

I managed to find a test case with K=40000 while keeping the answer as NO, and I think this is actually the worst case. Here's the code of the generator.

#include <cstdio>
using namespace std;

int main()
{
	int n = 40000, i, j;
	printf("%d\n", n);

	int cur = -10000;
	for (i = 0; i < n / 2; i++)
	{
		printf("5\n");
		printf("%d %d %d %d %d\n", cur, cur, cur, cur + 1, cur + 1);
		printf("5\n");
		printf("%d %d %d %d %d\n", cur, cur + 1, cur + 1, cur + 1, cur + 1);
		cur++;
	}
}
»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

not able to submit code and also not able to participate virtually in this.

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

    You can't practice or virtually participate during system testing.BTW system testing is over, you can try now.

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

can somebody explain why O(31·N) gets TLE in D? 38851723

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

    Worst case of .find() in unordered set is linear i.e O(n) in worst case making your code O(31*n^2).

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

      that is because of collisions but using int reduces the chances of collisions (good hash function of STL), unless the test case was crafted for making TLE.

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

        It's totally possible for someone to add a hack data to make such solutions fail. That's why you shouldn't leave any luck-based things in your code in educational / Div. 3 rounds :)

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

    thanks parth & djm03178 but the problem was pretty stupid, I computed v[i]+(1<<bits) and v[i]+(1<<(bits+1)) again and again, this increased runtime, caching these values passes TL.

    Never thought this addition can be so evil. 38877122

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

      Haha that's sad, but you still passed TL by a little margin. 38877547 is your code using set instead of unordered set and it's almost 3 times faster.

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

        unordered_set (C++17): 3790ms

        unordered_Set (C++14): 2729ms

        unordered_Set (C++11): 2995ms

        set (C++17): 1263ms

        set (C++14): 1341ms

        set (C++11): 1263ms

        Lesson learnt:

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

          That's not the lesson you should learn :)

          You need to understand that unordered_set works based on hashes and therefore, if somebody knows the hashing algorithm used, they can handcraft a test case for which the hashes will have many collisions.

          One popular technique to avoid this is to add a random seed to your hash function. That way, the hash function is different every time and it is very difficult to generate a bad test.

          Have a look at this submission 38889378. It is your code, but with a random element added. It passes in 1153 ms.

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

            thank you for this valuable information, but I think you forgot to take xor again when searching in set. This trick helped me reduce runtime to 998ms. 38890354

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

In problem D,My submission gets Ac , but I think it is wrong because I thought same numbers can be chosen the same time . However , x — x = 0 , and 0 is not 2^s . it can be simply hacked .just like 3 3 3 3

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

I am new to this platform.... Just wanted to know.... after how much time rating changes are updated?

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

    I'm still waiting for the ratings to get updated. I don't know why I takes so much time. Hmmmm...

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

      Because it's div3 with ACM ICPC rules and extended hackings (12 hours if I am not mistaken).

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

For D, solution1 using set passed, but solution2 using unordered_map got TLE. How does solution2 which use unordered_map tend to be slower than solution1 which uses set?

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

    Press Ctrl+F and type "unordered" and you'll find out similar questions and their answers.

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

Can anyone explain the approach/solution to problem F?

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

What is the required complexity for problem C)Equal sums?

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

Отличный проблемсет!

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

In D, why did I have to sort the coordinates array to not get TLE?

TLE submission: 38882910,

AC submission: 38883316.

Thanks in advance.

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

    The problem in your code is not the sorting, but that you use the [] operator for map look-ups, which creates a new element every time (check the documentation), therefore needlessly increasing your map's size.

    Use find or count when you want to do lookups without creating new entries. This submission 38889506 is your TLE code but with this bug fixed and it passes in 1107 ms.

    As for "why does it work when sorted", it just so happened that, by coincidence, if you sorted your data, you found a solution early on and exited your program before hitting the time limit :)

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

Is O(n^2) not enough for Problem D? n<2*10^5 and time limit is 4 sec.

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

    O(n^2) would be 4*10^10 operations. 1 sec is aproximately 10^8 operations,so order 10^10 is too much.

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

Can someone please explain intuition / approach behind solving Problem F?

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

    It's optimal to bring at most one umbrella at any time. To get minimum fatigue given the configuration of rains and umbrellas (position, weight) you can use DP 0-1 technique to consider whether to pick current umbrella (to survive the next rain) or not.

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

What's the difference between if (v.find(x) != v.end()) and if (find(v.begin(), v.end(), x) != v.end()). (v is a set/vector)

The former one got AC but the latter one got TLE? Please help.

  • »
    »
    6 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится
    set.find(x) - O(log(n))
    find(set.begin(), set.end(), x) - O(n)
    // set
    

    in the vector always find O(n)

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

      My vector v is sorted, that's to say, after sort(v.begin(), v.end());, does that mean it is also O(n) all the time?

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

        Yes. How с++ should understand that your vector is sorted. If you want to find the element in the sorted vector, you can use this:

        vector <int> a;
        //read
        sort(a.begin(), a.end());
        int i = lower_bound(a.begin(), a.end(), x) - a.begin();
        if (i < a.size() && a[i] == x) // yes
        else // no
        // O(log(n))
        
»
6 лет назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

Я тут уже целый час ищу русский текст, в надежде хоть что-то прочитать

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

volamtruyenkyii this guy has given his first ever contest and got 1st rank, great. But he has registered just 2 days ago, Well I think he is a high rated coder who has made a new handle just to get rank 1 in Div 3

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

    Not that it really matters, but regardless of his intentions I understand he should not be in the official results because it is stated that "only the trusted participants of the third division will be included in the official standings table" and he does not meet the requirements to be such (actually, he is not an official contestant in the "common standings" page, the thing is that he got included in the "official results" table of winners in this post)

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

It was my first time to get tagged in official codeforces round .. Awesome ^_^

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

I'm glad to be an expect through this round. ~ this is a lovely round. Thanks

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

hahaha i ac 5 rating from 1500 to 1691!!!!!!!