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

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

Привет всем!

CF раунд #333 (обе дивизионы) состоится сегодня. Авторы раунда — я и Baklazan.

Просто случайно, мои задачи пронумерованы чётно и задачи Баклажана пронумерованы нечётно. И тепер можете раздумать, если они пронумерованы от 0 или от 1 :D.

Как обычно, благодарим GlebsHP за его помощь (в частности, за помощи упростить некоторые задачи), MikeMirzayanov за CF и Polygon, Delinur за перевод условий задач на русский язык и тестерам misof, Mimino, AlexFetisov и winger.

Желаю хороших результатов и изменений рейтинга тем, кто их заслужат, и также всем сумма-нуль изменение рейтинга.

По традиции, разбалловка появиться прямо перед соревнованием.

Div.2: 500-1000-1500-2250-2250

Div.1: 500-1250-1250-2000-2500

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

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

A contest authored by Xellos! I bet the statements will be really funny!

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

"as well as a zero-sum rating update to everyone"?

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

    you can take this blog as an example. The amount of positive vote Xellos gets here is proportional to downvotes other get. so, the amount of all downvotes here including yours + the amount of upvote Xellos get is almost zero. Hope this helps.

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

the soonest announcement.

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

what do you mean of posting a programmer cat photo?

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

I think you have to swap links of (animated version, original)

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

You have also changed the screen of the laptop...:D

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

Deleted

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

А на русском нельзя написать?7??7?7? Не все тут британцы то всё-таки.

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

    КАК МОЖНО БЫТЬ ТАКИМ ДАУНОМ, ЧТОБЫ ЭТО ДИЗЛАЙКАТЬ?????????

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

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

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

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

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

Xellos write:

"I'm the author of even-indexed problems and Baklazan the author of odd-indexed problems"

So,The the index of the problems start with 0 or 1?(In other words,A Div2 indexed by 0 or 1?)

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

    Yes.

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

      Yes? :-/ What yes? :-/

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

        The the index of the problems start with 0 or 1?

        Yes, with 0 or 1.

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

          No,I say Which problem indexed by 0?(A div2,C div2,... or B div2,D div2). It seems that A div2,C div2,... are indexed by 0.(by reading you last answer.).Is it right?

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

            Why would you even consider the possibility of B div2 and above being indexed by 0? That would mean A div2 indexed by a negative number.

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

              if we indexed A by 1,B by 2 and ... ,problem B div2 ,D div2 and ... are even-indexed but if we indexed A by 0,B by 1 and ... ,problem A div2 ,C div2 and ... are odd-indexed.Is it out of mind?

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

                Is it out of mind?

                Yes — it's on screen.

                I can keep this up longer than you :D

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

                  Holy heck, you guys are pricks. The guys was asking a genuine question and all you do is downvote him. I mean, yeah sure it's fun messing around with someone for quite a while, but you know... You could just answer his question in one of the comments.

                  Oh and in case you're in the "hurr durr i is veri smart cant read broken englando"-zone, he asks:
                  "Since you are the author of even problems and Baklazan is the author of odd problems, does the indexation of problems begin with 0 or 1? In other words, which problems did you design: A, C, E, Div1 E or B, D, Div1 D?"

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

                  Why it's so hard to read the post?

                  I'm the author of even-indexed problems and Baklazan the author of odd-indexed problems. Now I'm going to let you wonder if it's 0-based or 1-based :D.

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

                  Oh, what a horrible thing I did! FYI I don't want to reveal it yet, so that people could read the problems in arbitrary/strategic order.

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

                  Since the debate reached its maximum indentation level, not sure who you guys talking to :p

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

                  In the comment headers, there are ^ and # links. Have you ever wondered what they mean?

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

                  No. I have better things to wonder, because.

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

Hi Xellos,

You did not mention Maria Belova (Delinur) in your round announcement. I'm guessing she did not do problem statement translations?

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

    Not yet, since the problem statements aren't ready yet. Mystery of the Early Announcement...

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

      I volunteer for problem statement translation, whenever they're ready.

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

        From English to English?

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

          What proof do you have that I am not Russian? Or, say, that I don't understand Russian?

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

            tu russian nahi Xellos ka kutta hay :D

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

              He's abusing Xellos, calling him dog. Google translate.

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

                So, I_love_Captain_America is Indian. But, Guys he is such an evil. Google can never translate any of my words: Click for Proof. The real translation is:

                "tu russian nahi" — means, you are not russian

                "Xellos ka kutta hay" — means, you are a bitch of Xellos

                I didn't abuse any dog calling Xellos.

                @Bullspeck, Why did you mislead a whole community against me? Learn to respect your own country. People like you are a shame to its own nation.

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

                  People here are not idiots. The link you gave doesn't translate shit. I translated words, not the whole rubbish you wrote.

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

                  I didn't abuse any dog calling Xellos.

                  Shame on you.

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

                  After he mentioned India, I translated using some Indian languages, and this is the result click

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

                  viesis, calling any human a dog is disrespectful. Did I_love_Captain_America/Xellos say anything disrespectful to you before you posted that? btw, the translation is wrong.

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

                  @ruhan, I think calling that I_love_Captain_America as bulldog would be fine. but if you think it is disrespectful to the dog-species then let's call this user ass whole, would it be ok?

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

                  Whatever, I have no interest to talk with you anymore.

                  If that is true, then why did you tag me in your next comment? I got an unnecessary mail in my inbox drawing my attention to your nonsense comments and forcing me to give you one final reply.

                  You illiterate dipshit dont you know how to use Google translate? There are many languages in the options as source language, and you uneducated shit using both source and destination as English facepalm

                  I used almost all the languages in drop down menu to come to the realization that the word means dog. I kept changing language till the word didn't translate to the word itself. Took 5-10 minutes that's all.I didn't know it was Indian language at the time, I just figured out what it meant.

                  I am not Russian, and I was shitposting about translating to Russian, for fun. But I am not Xellos' dog, you little twat-faced bitch. I will not respond to any more of your cum ments so GET THE F*** OUTTA HERE YOU BASTARD.

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

I don't know how to post gifs, but you can post this instead...

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

>contest will take place in a few days
>proceeds to schedule the contest in 16 days from the announcement

I'm calling shenanigans

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

    The "16 days" is when I made a template with pretty much nothing. Blog post "publishing" times can be misleading.

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

From now on, all(or most of) the contests are held in 'unusual' time, right? A 300000-millisecond-delay!

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

What's even-indexed problem if our eyes aren't real?

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

Cat. Keyboard. #include <string>?

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

So the main character of this round will be Pusheen? :D

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

negative votes please :)

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

Hey, why do you have to conduct all of your competitions on Tuesdays? I can neither participate in round #333 nor #334, because of a Tuesday schedule conflict. Can't you reschedule #334 on another day?

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

    There was a blog post about a week ago saying all competitions have been on Wednesdays and Thursdays (or Fridays?) recently. Actually, the statistics of standard CF rounds for the past 2 months including the upcoming contests is:

    • Monday — 1
    • Tuesday — 2
    • Wednesdays — 2
    • Thursday — 0
    • Friday — 3
    • Saturday — 1
    • Sunday — 3
    • »
      »
      »
      8 лет назад, # ^ |
        Проголосовать: нравится -23 Проголосовать: не нравится

      Well, at the very least it would be nice to not have two competitions on the same day of the week (Tuesday) in two CONSECUTIVE weeks, like the case is now... Is there a way to suggest this to admins?

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

        Is there a way to suggest this to admins?

        Yes, you can write to them.

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

Auto comment: topic has been updated by Xellos (previous revision, new revision, compare).

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

Gif is working :O

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

Is it rated?

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

MikeMirzayanov would be wrong to expect 333 coderforces t-shirt ( one extra for me to draw attention about it ) for this 333 round :D As 333 round comes only once in a codeforce life time we can expect 333 codeforces t-shirt :D

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

In the email CF sent
Attention! Unusual start time: the round starts on Tuesday, November, 24, 2015 16:35 (UTC).
but this is the usual time :D

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

Auto comment: topic has been updated by Xellos (previous revision, new revision, compare).

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

Nice Russian translation :D.

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

I am afraid of this contest :(((((

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

"сум-нуль"

Есть кто-нибудь, кто знает, что это значит?:D

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

    Нужно зайти на английскую версию поста.

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

    это значить, что сумма всех изменений рейтингов должна быть равна 0 — сказано одним словом...

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

Автори -> Авторы

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

Wow. The number of "This comment is hidden because of too negative feedback" comments is way too high for this blog post.

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

I've been shit-posting a lot for the last couple of months, hardly did any competitions, and hated solving problems altogether. I didn't realize that the reason I started hating it is because I've already solved the easy problems and the difficult ones are left. Today I got a real nice kick to think my actions over, and so, after this one, no more shit-posting, only learning and competing and repeat.

_< (So mad at myself)

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

Auto comment: topic has been updated by Xellos (previous revision, new revision, compare).

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

The Contest starts with Score distribution announcement :D

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

It's funny that ubuntu base64 couldn't decode ZDJsc2JDQmlaU0J5WlhabFlXeGxaQ0J5YVdkb2RDQmlaV1p2Y21VZ2RHaGxJR052Ym5SbGMzUWdL R0ZqWTI5eVpHbHVaeUIwYnlCMApjbUZrYVhScGIyNHBDZz09Cg==, but Mac base64 could.

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

ZDJsc2JDQmlaU0J5WlhabFlXeGxaQ0J5YVdkb2RDQmlaV1p2Y21VZ2RHaGxJR052Ym5SbGMzUWdL R0ZqWTI5eVpHbHVaeUIwYnlCMApjbUZrYVhScGIyNHBDZz09Cg==

Base64-decoded it ...

d2lsbCBiZSByZXZlYWxlZCByaWdodCBiZWZvcmUgdGhlIGNvbnRlc3QgKGFjY29yZGluZyB0byB0 cmFkaXRpb24pCg==

Base64-decoded it again ....

will be revealed right before the contest (according to tradition)

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

downvote me

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

if you are too lazy to double decode, here's the score distribution : Div. 1: 500-1250-1250-2000-2500 Div. 2: 500-1000-1500-2250-2250 glhf!

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

В определеннии константы Липшица подразумевается целая часть? Округляем вверх или вниз?

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

Hack Div.2 B выдает ошибка FAIL the absolute differences between consecutive A[i] must be <= 1 ()

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

Codeforces was down for me almost all the contest, I couldn't load the page at all, did this happen to anyone else?

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

    Codeforces was up for me almost all the contest, I could load the page without any trouble at all, did this happen to anyone else?

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

      I ask because this is the first time this happens to me, I tried with various internet connections, It took me over an hour to get to the front page.

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

Я аплодирую стоя авторам задач за умение обманывать.

UPD: Конкретнее — наверняка я не единственный, кто слишком поздно понял, что в A div1 один из видов транспорта сможет добраться до N города за единичку и вообще не будет мешать второму транспорту. То есть простой БФС, замаскированный под... что-то более сложное.

В B div1 у меня ушло много времени, чтобы осознать, что мы никогда не будем брать два числа на расстоянии больше единицы. Ну хотя тут это уже скорее что-то со мной не так, нежели авторы это замаскировали.

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

Very interesting problems...

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

Submitted solution of B in last 3 seconds and pretests passed! Phew, that was close!

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

    How did you solve it? Could you, please, explain? :)

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

      Div 2 B was DP . dp[i][0] = longest sequence such that its last element is a[i] and it is the smallest element in the sequence Similarly, for dp[i][1] (if a[i] is the largest element in the sequence) Transitions are : 1 . a[i+1] — a[i] = 1 : dp[i+1][1] = dp[i][0] + 1 2. a[i] — a[i+1] = 1 : dp[i+1][0] = dp[i][1] + 1 3. a[i] = a[i+1] : dp[i+1][j] = dp[i][j]+1

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

        I also have a solution without dp.We can deal with the initial array a to a new array p so that the continous same element will combine.Then for each p[i] we find left_max and right_max and judge whether they can be combined.But this solution is n^2 , we can use a array v to mark the element we have dealed . Because once it was dealed , we dont have to deal it twice. By this trick,it will be a O(n) solution.And thank you for your solution, you know i am not good at dp:) I will deal it with dp tonight:)

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

      It's two pointer approach question. We start from i=0 and left=0 and keep track of minimum and maximum elements while traversing and we stop when abs(a[i]-minimum)>1 or abs(a[i]-maximum)>1. Then if(abs(a[i]-minimum)>1) we put left=minimum index + 1 and if(abs(a[i]-maximum)>1) we put left = maximum index + 1. Then again we start traversing with i and these steps repeat until i!=n.

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

    It looks like the pretests are very weak. I submitted two solutions to C that had a bug in them and passed the pretests.

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

jqdai0815 solved from E to A, like in a div.2 round :'(

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

That sudden realization 5 minutes before end of contest, that if first city doesn't have a road to the target city, means it has a railroad to that city. So it's a one-dimensional BFS then...

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

почему в B в Div2 проходило N^2? (на претесты только)

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

    Я думаю, что после системного тестирование N^2 решение упадет.

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

Div-2 A: I think many forgot the fact that pow(x,y) != ceil(pow(x,y)) Hacked 6 in my room with

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

    How? it should be a simple if(25>24) — I used manual powers tho.

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

      25 > 24, but pow(5,2) will return 24.9x, so if you store it as long long, it will get stored as 24.

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

        on my compiler long long x = pow(5,2) returns x = 25

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

          You can try this :

          for(i=2;i<=40;++i){
              for(j=0;j<=10;++j){
                  if( ((long long)ceil(pow(i,j)) - (long long)pow(i,j)) !=0 ){
                      cout<<i<<" "<<j<<"\n";
                  }
              }
          }
          
          • »
            »
            »
            »
            »
            »
            8 лет назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            I am unable to understand why could that happen. I tried this on my system, as well as on ideone — link. Both terminate without any output.

            Could you provide an insight on why would pow(5,2) be 24.9 and not exactly 25?

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

              Because pow accepts it as a double and double being a floating point type has precision issues. http://www.cplusplus.com/reference/cmath/pow/

              Kind of similar why one cannot compare doubles precisely.

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

                But same thing runs fine on my system as well as on online compilers. Why should that behave differently on codeforces?

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

              I don't know the exact reason. The output depends on the compiler I guess. I use Codeblocks and I got (long long)pow(5,2) = 24

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

That was really tough I tried to solve problem A by converting all values to base 10 and then comparing them,like this,but I kept getting the sum as 0,don't know why,could anyone help?

int power = 0;
int  sum = 0;
int s = n - 1;
for(int s; s <= 0 ;s--){
    int l = x[s] * pow(bx,power);
    cout << l;
    int sum = sum + l;

    power++;
}
cout << sum;
  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Why do you set int s = n-1 outside the loop then make a new variable with the same name inside it?

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

    You're declaring a new variable called sum inside the loop. Change int sum = sum + l; -> sum = sum + l; so that it updates the outer scope's sum.

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

      I updated it to this I still get 0 as sum

      int power = 0;
      int  sum = 0;
      for(int s = n - 1; s <= 0 ;s--){
          int l = x[s] * pow(bx,power);
          cout << l;
          sum = sum + l;
          cout << sum;
      
          power++;
      }
      cout << sum;
      
  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Why are you declaring int s inside for loop??

    Should it not be ~~~~~ for(s; s <= 0 ;s--) ~~~~~

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

i started contest 40 minutes late but it was fantastic!

thanks Xellos ! :D

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

Div2D can be reduced to finding sum of max (a[i]..a[j]) with l <= i <= j <= r.

Again, headshot-ed by D. Even O(N log N*Q) solution get TLE. Is there a way to solve D in O(N*Q)?

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

И так скоро будут разбори, но как кто решал Div2.E?

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

Could someone tell me what the hell is wrong with my code??? http://codeforces.com/contest/602/submission/14455186

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

    Phew finally found it. Try this

    7

    1 1 2 2 3 3 3

    Your code gives 4 but answer is 5.

    PS — You need to update the value of maxVal and minVal as you traverse through input that's where the problem lies.

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

Nice contest. I wish i hadn't wasted much time on B though and moved to C directly :\ I am not even sure for B but C was sure if i could submit in time :\ So yeah i was right, 5 more minute would have made it for me :( http://codeforces.com/problemset/problem/602/C --> http://codeforces.com/contest/602/submission/14457506

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

I was very close to do an unsuccessful hack because of this pearl:

#define int long long

I guess it helps some coders to not even think about overflow cases but I can imagine many people have fallen for it and failed their hacks. What do you guys think?

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

    Right at the same time I complained about the same subject !

    And unfortunately this trap screwed me in hacking :[

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

    I made the exact same mistake last contest. A smart idea actually since ratings is a zero-sum game.

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

4 unsuccessful hacking attempts !

2 of them defined int as long long on A, what's wrong with you people ?

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

For problem C, suppose that the condition that "all pairs of nodes without a railroad connecting them must have a road connecting them" was removed. How then could we solve this problem?

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

    2D BFS (my actual solution without realizing the condition you mentioned, probably failed)

    In a node of a BFS you save position of the bus and the train. Then when you dequeue it, you add all the nodes where bus can go * where train can go, except if their destionations equal.

    So, if the state is (2,3) it means bus is at the 2nd node and train is at the 3rd node. Then you look where bus can go: for each destionation you look where train can go (except the same destinations) and add them to the queue if they are not visited.

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

      We can just do it with bfs. Train or bus will get to the city n in 1 hour for sure, because the edge (1,n) belong to bus or to train. For transport, that can't do it, we can just do bfs.

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

        The user I answered to asked what if the condition that train or bus will have a road to the target city would be removed, meaning what if there would be pairs of cities without any roads inbetween.

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

A new legendary grandmaster is born...

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

It took me 15min to pass pretests on Div1 B, and then I spent over an hour trying to get an idea of Div1 C, even though they were valued the same :\ . What did I miss? What's the approach for Div1 C?

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

    There are 2 steps here:

    1. Use linearity of expectation --> you only need to care about 1 opponent.
    2. Use DP to calculate the probability that the opponent has better score
    • »
      »
      »
      8 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I'm not sure I understand. So what if I find the probability that one opponents has better score? How does it scale to M opponents?

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

        E(# participants with better score)

        = (M-1) * E(1 participant has better score)

        = (M-1) * (probability that 1 participant has better score).

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

      I got to step 2, knew it was DP but couldn't figure out how to do it. Looking through the solutions, I see something with prefix sums and a DP table of dp[processed races][current sum], but still don't know how it works :(

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

Really sorry for them whom are getting WA on 45 in DIV2 A.....I think many of you don't know pow function doesn't work appropriately in codeforces.

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

What's the solution of Div1 B?

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

По моему, на задачу B были слабые тесты. Мое решение с ошибкой которое выдавало на тест

4
5 3 3 3

ответ 1 вместо 3, как-то прошло все тесты.

Я сильно удивился, когда увидел это.

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

    Разность между двумя соседними числами должна быть не больше единицы по модулю.

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

What may be the reason of WA40 in div1A?

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

    Maybe you use pow in c++, which is incorrect. Try this test:

    10 10
    9 9 9 9 9 9 9 9 9 9
    9 16
    2 5 4 0 11 14 3 15 15
    

    Answer: =.

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

    Using an stl function pow.

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

    Seems we fail if the parity is wrong and there are no cycles to fix it or something. I don't have the edge n->n so it has to go away and return.

    e.g.

    I give 3 for

    3 1
    1 3
    

    The method has no observation about one takes 1->n immediately, just does a BFS on the state (train at, truck at, who moved last).

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

      Here was irrelevant message about other problem. Thanks for downvoting instead of simply explaining it.

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

i have solved problem C with O(n^3)! will it get TL?

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

How to solve Div 2 C. Is it some kind of 2D BFS ? Can anyone share the approach ?

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

    if there is an edge from 1 -> N then we can do a bfs for road system and report the distance of N from 1 , if there is no edge from 1 -> N , there is a road from 1 -> N so we can use that and find distance from 1 to N in rail network and print the distance of N from 1 using rail.

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

      Thanks! I missed the observation that edge 1->N exists either for rail or for road network.

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

    No, it is simple 1D BFS, you just need the observation that the there is a road or railway from city 1 to N that will take one hour that is only available for one vehicle and you just need to compute the shortest path of the vehicle that didn't have this edge.

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

    I realized only afterward that if the traintrack isn't directly connected to the end position, then a road MUST be. So the Min time for either the train or the bus is 1. Then, from there on it's a straight up BFS over all the positions and the min number of steps to get to the end is the answer. I still solved it, just rather stupidly...

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

How to solve Div2 B? What is the main idea?

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

very good contest!thank you a lot!

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

In this round fest and Shadow are cheaters.

Here are their solutions for B:

14455597

14455707

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

Could you explain what does the name of div1D mean? In Russian it's pretty nonsense not related to the problem (or I'm too dumb to notice it).

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

    It has no connection to the problem other than what a tree with any letters is in chemistry. (Organic chemistry really has a letter for everything — R stands for "anything", for example.)

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

I'm actually stunned of how test cases are so strong for problem C and weak for problem B. If you want to know what I mean look at this submission. http://codeforces.com/contest/602/submission/14448575 and got Accepted! with complexity O(n^2)

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

    Wow, so there was no need for dp. Now this really looks like a div2B problem.

    I need to adjust my assumptions about the speed of codeforces machines, so maybe next time I'll do better in the contest :)

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

I enjoyed all problems so thank you for a round Baklazan and Xellos.

Though I don't like your editorial. Hints are better than no editorial at all but I would prefer to be able to decide if I want to read whole solution immediately.

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

    I would prefer to be able to format everything properly immediately. But we don't always get what we want.

    This is still better than waiting for everything at once.

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

    Where is the editorial?

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

I am getting correct answer on my PC but WA in CF: http://codeforces.com/contest/602/submission/14455593

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

    During Educational Codeforces Round 1 hacking, I found distinct answer for a same code ran in my PC and CF. However, I didn't know why.

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

Admins Please take a note on this. Strange thing happened I don't know the reasong.
In my solution 14444210 to the Div 2: prob A. It says wrong answer to test case 45. I have tested with the same test case in my system as well as in ideone.com here and gives the correct output.
Please look into the matter. Thank You

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

    You used pow function which gives say pow(5,2) is 24.999999. So when you take the long long you actually get 24...

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

      but then why does it work on my pc (using g++ btw in linux system just in case) and also the online compilers. And that makes pow totally worthless!!

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

        I am not entirely sure, but once I put round() around my pow function, it worked.

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

          K... I had to implement my own pow function to get it accepted!! Btw thanks... I am not going to use pow again!! it was strange tho!!

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

Nice problems and nice day. But I still don't know why I get RE on pretest 8 in Problem B div.2 for my first solution.

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

What is the reasoning for not including any big tests to break single hashing in pretests?

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

    Well. Why would they want such a test in pretests?

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

      I mean, pretests should test basic correctness. If the solution is going to fail on most big tests, it seems to me pretests should check that.

      Most of the reasoning for weak pretests is for hacking. (right?) D's don't get hacked a lot and it's pretty risky to hack so it doesn't seem to serve this purpose. I guess this is mostly about the point of system testing, which I don't think is to make people fail.

      Well, anyway I guess I shouldn't assume that such tests are included next time and just double-hash to begin with :/

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

        I think you should estimate the probability of collision first. https://en.wikipedia.org/wiki/Birthday_problem

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

          You are absolutely right about checking probability. I mostly was thinking that pretests would catch bad solutions (as per CF's increasing tendency to have strong pretests, maxtests, etc.) Rather, I'm referring to what seems to me intentionally failing these tests in systests rather than pretests: (Also re: desert97)

          I was assuming that the authors let hashes pass pretests intentionally and fail later, not just randomly. This is based on statements like "which is why there are anti-hash tests :D" (which might be referring to abbabaab... instead), but also how almost all hashers failed test 13, even with different hash systems.

          If this is correct, this is the thing that seems kinda bad to me since it's just there to make people fail. I feel like that's what pretests are for and designed to do — make it so people don't think their solution is right when it actually has a big problem. Of course hacks lessen this problem, but who hacks on D? (oops rev1 was correct...)

          I'm also a little annoyed at dropping from 10th to 105th due to systests :/, but I think I would still think the same way if I passed. Pretests are something that have always been a bit strange, and I guess I would appreciate a bit more clarity and consistency on their purpose.

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

        I think the above thought process (referring to waterfalls's post) is not correct. Think about it this way:

        Say there are 10 pretests (standard) and 60 total tests. Say that there is a probability p that you get hash collisions. (One can compute p with some NT maybe...) Let's assume p is fairly small.

        The probability that you pass all pretests is: (1 - p)10. The probability that you pass all tests given that you pass pretests is

        (1 - (1 - p)50) ≈ (1 - p)10·(1 - (1 - 50p)) = 50p. So if p is something like 1 / 100,  you'll pass all pretests with something like 90% chance, but pass all final tests given that you passed pretests with only 50% chance. It could just be a probability thing. The 90% is probably even an overestimate given that most pretests are very small cases, so p ≈ 0 in those tests.

        If I did shitty math, please tell me.

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

      In problem B of division 2 O(N^2) is passing system testing

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

Good problemset I'd say.

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

My solution has been skipped ...

I do the Contest & solve the Problem for Upgrading my Rating ... then why this types of injustice ... Watch my submissions ... They didn't match to any others but any others submissions match to mine ... But why should I get the Penalty of rating loss?? what type of injustice is that ???

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

OMG, waiting for rate changing will kill me one time.

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

Auto comment: topic has been updated by Xellos (previous revision, new revision, compare).

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

for problem(A): My code passed all pretests but was rejected in systesting on testcase#45. When I run this testcase in my pc its giving correct answer, u can see my code in my submissions.

Test: #45, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 1, verdict: WRONG_ANSWER Input 9 39 10 20 16 36 30 29 28 9 8 9 38 12 36 10 22 6 3 19 12 34 Output < Answer = Checker Log wrong answer 1st words differ — expected: '=', found: '<'

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

    dont use power function. your code power function does not work correctly.

    so, if a=2,and b=3; find a^b; for(int i=1;i<b;i++) { a=a*a;

    }

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

      where does it not wok properly? why its working on my pc and not on codeforces ? plz explain.

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

Now it is midnight,but still wait for rating. After brainstorming ,pain in the brain. So,plz give the rating as soon as possible.

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

It seems that many O(N^2) algorithm are passing system tests for test B. I think the solutions for atleast B should be rejudged.

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

    yeah, now today was surely a bad day I solved 2 problems within 50 mins and both of them was rejected during system testing and I dont't know why . for problem A if the power function doesn't work , then it should give wrong in my pc too but when i checked ,the answer is correct in my pc.for problem B its giving TLE after system testing. Is anybody having the same problem ? can anyone explain me why this mismatch is happening?

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

      Man i am saying that O(n^2) solutions are not bound to pass because n=100000 but i saw various problems in which it is passing in 1900ms

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

      fnf47 do you have wrong answer on test 45 on problem A?

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

        yes JustInCase in system testing it gives wrong but is fine when i run it on my pc.I read the above comments but still the concept behind this is not clear to me .There must be some valid logic behind this.

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

          Do you use pow function?

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

            yes,and now its accepted . I used ceil(pow()) instead of just pow(). But one thing is still bothering me , if pow(a,b) gives wrong result on codeforces for some a,b then why its correct on my system?

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

              The way that mathematical operations are done on each computer can be different as different processors can use slightly different algorithms for certain mathematical operations. If you went out and bought the exact computer they are working on and compiled with the same compiler, you would get the same result as on CF.

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

Мне одному кажется странным что в топ30 ни одного нового пользователя? ^_^

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

When will rating changes be updated?

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

http://codeforces.com/contest/602/submission/14446757

Guys, someone hacked my solution with TLE. Why isn't it passing, it's O(N^2) on 10e6 max

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

Editorial...

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

I had the problem after the contest finished: the judge skip my 2 solutions for A and B. I have taken part in more than 100 contests of Codeforces and although I didn't do it well, I never cheat or do something like this. I don't know why. :(

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

I tried Div2 B in Java during the contest : link

and got TLE in test case #22 in the main tests

Then, I tried submitting the same code in C++ : link

I've used the same logic for both the solutions, yet the C++ solution actually gives TLE only on test case #31.

Why is the solution time not adjusted depending on the languages? :/

Well, yes, this time it didn't make any difference, but some other time, maybe it would?

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

А где разбор?

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

What a likeness!!!
(602B - Аппроксимизация постоянного диапазона)=((6E - Экспозиция)-(cout<<b<<endl;))
It was enough to copy and paste someones code to get accept in this task.
Just read both problems.