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

Автор PraveenDhinwa, 12 лет назад, перевод, По-русски

Codeforces Round #251 для участников из второго дивизиона стартует в среду 4 июня в 19:30 MSK (обычное время). Традиционно мы приглашаем на внеконкурсное соревнование участников первого дивизиона.

Раунд был подготовлен мной (PraveenDhinwa). И это первый раз, когда я выступаю в качестве автора Codeforces Round. Я очень старался сделать условия задач как можно более понятными, надеюсь, что раунд вам понравится.

Отдельное спасибо Геральду (Gerald) за помощь в подготовке соревнования. Также хочется поблагодарить Pratik Moona(pratikmoona), Varun Nitish(JuanMata) за тестирование раунда. Их помощь была неоценима! Благодарю Devendra Agrawal(devu) и Utkarsh Lath(utkarshl), они помогали мне верифицировать правильность идей в задачах. Спасибо Михаилу Мирзаянову (MikeMirzayanov) за создание этой замечательной платформы для поведения соревнований.

Задачи сегодняшнего контеста посвящаются моему дорогому другу Devu (devu). Однажды он сделал задачу с названием "Churu — вор". Churu — это мой ник-нейм. Теперь пришло время отомстить!

Распределение баллов по задачам будет стандартным: 500-1000-1500-2000-2500.

Еще одна хорошая новость состоит в том, что разбор задач будет доступен сразу после окончания контеста.

Желаю всем высокого рейтинга, удовольствия от решения задач и множество взломов!

UPD

Editorial

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

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

@PraveenDhinwa I guess you are the first Indian Problem Setter (that too from my college :) ) on Codeforces (at least from the time I have joined Codeforces) .. Congrats .. Will definitely participate !!

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

LOL score distribution's available from the beginning :D

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

AFAIR, devu named it "Dhinwa Chor" not "Churu, the thief", which was later renamed "Dorsey Thief" before the contest.

For Non-Hindi speaker, Chor == Thief

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

Congrats PraveenDhinwa will surely participate :)

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

I hope this round problems can be described more clearly. It is important for me to start the contest and I am raring to go. :)

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

is devu the author (or tester) of the problem Devu Vs Police? i really liked that problem! :)

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

    He was the author of the problem :)

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

    Thanks :D

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

      actually, thank you for creating such an awesome problem. it was by far the hardest i have ever worked to solve a problem since i started competing in online contests.
      and as u can see from my AC solution, i used CRT and ETF (two concepts i barely knew, and had no pre-written code for), along with a few small "tricks", to solve it. was that the intended solution?

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

        In my opinion, CRT is unnecessary — you need only fast modular exponentation and ETF.

        Of course (from Euler's theorem) we know that . So, for example, φ(10) = 4 and then

        In your task you can see that (if n ≥ 2)

        So you need to do only the following things:

        • compute k = φ(n).

        • find (use the modular exponentation); let's say the result is e.

        • find (again modular exponentation).

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

          But it can happen that (a, n) ≠ 1 and so, your idea will not always work.

          My idea was to factorize n and do some stuff which I forgot(and don't understand from my code) :P

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

            Oops, true. I didn't notice the lack of the assumption :D

            However, I'm almost sure the following trick works: we can write a = xy, where x contains all the prime divisors which are both in a and n (for example, if a = 2734527 and n = 233911, then x = 2734 and y = 527). We do the same for n: n = zt (in the example above, z = 2339, t = 11). Result is then

            We can compute second factor as I mentioned previously (just because (y, n) = 1). What about the first one?

            • If the exponent (b·cd) is quite small (less than or just 30), we can brute-force it.
            • In the opposite case note xb·cd is surely divisible by z (compare the exponents). Then we just have to compute , which is doable using my previous post ((x, t) = 1) and then just multiply our result by z.

            I hope it's understandable (and moreover, that it's true) ;)

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

Everything is happening quickly of this round.. :)
quick announcement, quick score distribution & quick editorial too... :)
hope, will enjoy this contest... :)

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

I wish all the participants ..... lot of hacks :)

I guess the problems are going to be hackable :D

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

The prose in these announcements is getting better over time. Wish everybody high scores. Happy coding!

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

Just look these unrated registrants

I really try to be dewy-eyed and think all the 400 unrated users that register for every Div2 only contest are real...

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

If I have registered but I can't participate any more will it affect my rating? Sorry for newbie question...

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

an unrated user named smart_lovely_JuanMata is currently leading the Standings.
seems like a fake account to me, but i can't say for sure now.

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

As the round closes, I'd like to commend the round writers. Even though the contest was slightly easier (I, who usually gets only one problem, solved 3), I loved the problems and how each and every one of them were easy sounding but had something to figure out.

Thanks for my favorite problems so far!

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

Обожаю раунды с возможностью с лихвой поломать решения конкурентов! Thx PraveenDhinwa

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

Когда меня взломали, во вкладке задачи она была зеленая. И еще было бы круто чтобы в кларе был вердикт взлома.

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

Did anyone who solved D used Binary Search?

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

У меня на контесте 2 возможных расклада событий:

  1. Я либо решаю A, B, C, не делаю взломов, а потом огорчаюсь тем, что их было так много

  2. Или же решаю A, B, жестко туплю на C и делаю +6 взломов :D

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

Как решать D?

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

Will DmitriyH count how many hacks were in this round?)

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

Really nice contest :) I think problem D should have had a 32-bit integer overflow warning...

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

Any ideas for problem E?

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

    I used inclusion-exclusion principle. And it passes the sample tests :D

    I count number of bad distributions, like distributions that can be divided by 5, 7 etc. Then using IE principle I exclude 5*7 divisors etc. This works in O(Q*(2^7)). the number 7 is due to the fact that 2*3*5*7*11*13*17 is bigger than 10^5.

    But I was not able to submit in time :|

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

    There is at most ~7 prime numbers which divides n.

    Tip : Solution is q * (2 ^ 7).

    EDIT: i did not saw Dixtosa.

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

    I think about the following solution but I got WA2. First of all, lets calculate how many solutions has quality n = a1 + ... + af , where ai >  = 1. We can do in C(n - 1, f - 1) ways(this is well-known problem). Then if gcd(ai) = x > 1 then x|n. So try to iterate all dividers of n, and for all such x, subtract from our answer C(x - 1, f - 1). Is it correct?

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

    Quite simple if you use Möbius inversion formula. There are much harder problems on SPOJ, as PGCD, and so on....

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

I think that many submissions to Problem B will fail the system test because of integer overflow, both a[] and x should be long long.

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

superround, thanks for authors!

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

System Tests. Please

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

Быстрый разбор-это очень хорошо.

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

in this round 251 div2...i submitted the problem Devu the dumb guy and got all pretests passed....nd got score of 680....but in few minutes i saw the status of my submitted problem as hacked....finally my score dropped to -1.....what it means...??how to prevent it>> ????

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

good tricky contest ^_^

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

Hey where is the editorial? It is disappeared!

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

I really wish people would stop using the anti-quicksort test. I'll agree it's a valid hack, but it's something that shouldn't disqualify a correct algorithmic solution...

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

the Best and Most Secure way for problem B: #define int long long
=))

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

everyone in system test

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

user "rationality" alone has +18 hacks!! o.O

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

Hello, I'd like to bring attention to the following code, it's for problem B with complexity of O(NlogN). But it got TLE, I can't find an explanation for this behaviour. My code template is rather large but it is ok, you can rest assure about that since I'm using this template for last 10+ contests. Only getInput() and solveCase() methods are relevant here.

http://mirror.codeforces.com/contest/439/submission/6799372

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

Было бы круто, если бы при онли див.2 раундах для учасников из первого дивизиона висело напоминание о регистрации. Оно вроде бы и фигня, но я так уже не первый контест провтычил =(

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

So many solutions of Problem C failed in system test. So spectacular...

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

Не видел еще контест, где там много валится на систестах)

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

How can I calculate my new rating?!

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

Problem B was really easier than problem A! Pretest 3 was ... I regret why i didn't go to solve B before A.

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

Why there are so many hacks on problem B? I can't find any tricky test cases :(

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

Офигеть, сколько WA! А у меня вообще ошибка исполнения :)

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

Can someone tell me, is there any test in task C with K = 0? I found it, when i had got only five minutes left before the end of the contest, so i lost lots of points...

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

who can tell me why my solution of C my solution wa on 58 test

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

I will forget int in C++ and I will never use it again. By the way, Do you know what data type is int in C++, because I only know long long data type.

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

Problem C rocks!!

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

The most interesting contest I have ever solved! Amazing! I was really enjoying while solving problem C! Really unexpected idea! thanks authors for the contest!

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

Damn . I failed system test on problem C , just because I forgot to comment one line while Debugging .

It was surprising to find that it even passed the pretests with that terrible mistake .

It is so frustrating to see that the after that commenting that line , the code passed all the system test cases. I just missed an oppurtunity to go blue .... :(

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

Can anybody tell me what is wrong with my C solution. The judge says "wrong output format Extra information in the output file" in test case #58 and I can't see any problem with my solution. Thanks in advance.

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

What the ...
Wrong answer on test 71
A corner point that I thought about that but got confused with parameteres while coding
A line was needed to accept C
6809803 -> 6811297
What a stupid mistake :(
Someone helps me. I'm really sad :'(

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

problem C

http://mirror.codeforces.com/contest/439/submission/6807018 plz explain why my code gives wrong ans . thnaks

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

I locked my problem from dashboard and then went to standings to hack solution. But I was able to open hack window for my submitted code. When I double clicked on someone else's solution then it just showed pretest passed,etc.. Clicking on submission number didnt open the hack window. What was I doing wrong?

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

Failed problem D because of implicit transformation of an integer and failed C because of i failed to copy paste some validation made on the even numbers to the odd numbers... Missed the spot 45 because of two errors...

Anyways, congratulations because of the contest, well made, i understood without any trouble all statements.

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

There's an hour passed but there is no rating updates! Why..?

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

I was just going through different submissions of problem C, and came across this solution 6802980 which shows wrong answer for test case 44, but the output seems correct. Could you kindly tell how is that answer wrong?

Got it Didnt see the number of elements :P

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

my best contest ever, that's actually the first time i solve problem D in a contest really hats off to problem setters!.

i still wonders why a lot of participants failed in problem C?

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

For problem C, I am getting following output on my machine for test #3

YES

2 7 5

2 1 2

1 3

But the judge is showing NO as output. Can anyone please help me to figure out where is the problem? Submision ID : 6809178. Thanks!

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

Rating is updated... :)
seems your wish has suited me a lot... :)
thanks for nice contest... :)

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

Congratulations for the round! I loved the problems because they were more idea-based than algorithm-based. Also, I liked E because I don't find as many PINEX problems as I want to usually, so thank you!

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

Finally , I reached DIV1 :D

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

Problem C : I Got "Runtime error on test 60" :( in this 6806998 . What is special about it? :'(

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

Не заметив этой строки, попробовал 3 взлома на переполнение.

#define int long long int
»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

I've got RTE in problem C (test 20). I used queue with operations push and pop. After the contest, I changed queue to vector, only operation push_back, and I've got AC. Why RTE? Link to my submission: http://mirror.codeforces.com/contest/439/submission/6805127

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

Enjoyed the contest. Specially problem C though failed on test 24.

Thank you. :)

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

Can one look at my submission and see what's different from PraveenDhinwa's editorial?

My submission: 6799361 Praveen's submission: 6814439

both look functionally equivalent to me but, I got WA

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

When I submit the solution: the status is "in queue", waste many time. Can you fix it :D

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

Where is DmitriyH statistics? I missed them :)