Блог пользователя Erfan.aa

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

Всем привет!

Приглашаю вас поучаствовать в Codeforces Round #261 (Div.2 only), который начнется 15-го августа в 19:30 по московскому времени.

Раунд был подготовлен группой авторов: ShayanH, Haghani и я. Это наш первый раунд Codeforces, надеемся, что он вам понравится. Благодарим mruxim за его помощь в подготовке раунда.

Традиционно благодарим Gerald за его помощь и MikeMirzayanov за отличную систему Polygon.

Два главных героя легенд сегодняшнего раунда: Пашмак и Пармида — влюбленная парочка.

Распределение баллов по задачам будет анонсировано позднее.

Удачи! ;)

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

UPD2: Мы рекомендуем вам прочитать все задачи, несмотря на то, что они расположены в порядке увеличения предполагаемой сложности.

UPD3: Мы также благодарим Aksenov239 за помощь в работе над русскими условиями задач.

UDP4: Контест закончился!

Мои поздравления всем, кто решил пять задач.

Ниже приведен список семи самых лучших участников:

  1. vanhanh.pham

  2. ElemeNtLz

  3. MLboy

  4. mssjtxwd

  5. yyfkiller3

  6. phidang

  7. roben_76

Разбор будет опубликован совсем скоро.

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

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

Codeforces Round #260?

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

It seems that some time after Round #261 gets over, the World Finals of Code Jam 2014 will begin.

Link to live stream on YouTube

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

wow :) iranian contest I love them :)

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

Great! Finally Div 2 comes. I'll try to use Java in this round. ..

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

Хороша конечно идея ставить контест на вечер пятницы:(

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

hope for many hacks and no [pure] math :D

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

Hope for no hacks (strong pretest) and much [pure] math

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

Iranian contest :)

And better than this it's prepared by Allame Helli students :)

Wish luck for all participants :)

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

Waiting for a great contest from our friends! :)

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

It seems that I need another account..

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

q

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

a

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

Nice couple =)) Parmida & Pashmak :D

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

Another contest another new things to Learn wow!!!! Thanx codeforces :)

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

Опубликуйте перевод анонса для не англоговорящих неудачников.

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

Can't wait to meet. Pashmak and Parmida. Hope the couples are really nice with their problems need dp,math and maybe geometry.

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

just god knows who is Pashmak! somebody with a lot of short pashms? :D

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

give me "-" pls

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

Today is the Independence Day in India!

Wish all Indians a good luck.

Give your best today!

Jai Hind

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

    I could never understand ethnic of national pride. Because to me pride should be reserved for
    something you achieve or attain on your own, not something that happens by accident of birth.
    Being Irish isn't a skill, it's a fuckin' genetic accident. You wouldn't say "I'm proud to be 5'1 1. I'm proud
    to have a predisposition for colon cancer." So why the fuck would you be proud to be Irish, or proud to be Italian, or American or anything?
    (c) George Carlin

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

      Because maybe ethnic pride is not about oneself but about one's country. I think that "I'm proud to be an X", means that you like an X, you are proud of people of your country and you are happy that you are a member of this group. I don't know if it would be intelligent enough to interpret it as one's achievement :)

      I don't understand why the yash gets so many negative votes. Usually, people tend to be individualists and they are not united enough. So the guy has the right values.

      Likewise, I don't understand, why so obvious thought from quisorci gets so many positive votes. Moreover, swear words never strengthen ones position, I think :)

      Feel free to downvote my comment, I don't care about the contribution at all :)

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

        "I don't understand why..."

        Hmm, because society just tired of this nonending "today is some religious(usually muslim) or national holiday, so I wish good luck for the next nations: ..." phrases. It seems little bit egoistic and unpleasant. Have you seen at least once smth like "today is an Orthodoxian holiday, so, do your best Russians"?

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

          Nothing to add here. You've outlined all of my thoughts.

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

          That's not the problem in their national pride, that's all I wanted to say. I agree with you as people from some regions tend to write about their holidays more and some others don't write at all.

          I don't understand their feelings and most of their holidays, but I don't downvote (mainly because I don't understand it). For me, it is much more convenient just to skip them. I am not sure if he offends any other people with wishing good luck to Indians and expressing good feelings about oneself. If some people feel unpleasantly so aren't they egoistic too? :)

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

      If you would like to know it, then you should explore about the Great Indian Freedom Struggle!

      This day fills almost all of us with great positive energy to give our best!

      I have changed the photo as it was causing unnecessary troubles. Frankly, I had not read that statement (of pride) seriously!

      It had the map, the tricolour and the national anthem, so I posted it. Also, I had just taken the image from google and not MADE it.

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

hope short problem statement , short solutions , long editorial :)

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

Hoping for the best problem set =)

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

В письме на почту говорится, что соревнование для тех, кто новичок или у кого рейтинг меньше 1700. Те, у кого он больше, для них раунд нерейтинговый?

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

Задачи идут по возрастанию сложности или случайным образом?

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

Dynamic scoring will be used. The problems are gonna be ordered by their difficulty?

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

gl&&hf!

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

I know this is off topic question, but this guy FreezingCool has rating 1889 and he's not purple :-). Looks like an issue.

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

Too many registrants today...
4716 registrants...
I'm scared, as there may be in queue problem today... :(

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

    Soooooooooo many contestants that out-of-competition participants have to use 4-digit room number :p

    Maybe it is a record high register number for a single division contest :p

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

Whee! Full score in half an hour!

Kinda easy, no?

UPD: Also, my room only has unofficial participants. Lolwut...

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

Got My answer already... with losing Problem B......

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

Great contest! It was easy somehow (this is div2 it shouldn't be hard) , but it had so many good things by the way!

for example there existed a huge test in pretest that we don't get Run Error by getting max n , 10^5 or something like this! (I got runtime error during contest!)

also problem statements were so good and easy to understand!

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

A,B too easy! C,D too hard! :D

Hope there will be an complete editorial for the hard problems.

Thanks

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

Tremendous contest for division 2. Thanks to you, author, my depression is over :)

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

The easiest hack was for problem A. Half the people in my room that solved the problem didn't use if (abs(x2-x1) == abs(y2-y1), or some variant of that. They mostly used if (x2-x1 == y2-y1). Therefore, they could not pass the test case (x1==10, y1==-10, x2==-10, y2==10). x1-x2 would be -1 * y1 — y2. Therefore, they would output "-1" when there was an optimal solution. I got 500 points this way :)

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

I liked the contest and the difficulty was ok for div2. Also , very nice problem C. Congrats !

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

Very Weak Pretest !! I am really afraid about system testing !!

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

Пройдет ли в D решение за Nlog2(N) с деревом отрезков по времени? А то у меня на тесте

10^6
1 2 3 ...

Работало ~10 секунд ._.

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

Nice contest (also the first time for me to pass pretests on all problems). For me C was the hardest problem in today's set. What made C so hard for me was realizing the proof that splitting the students in groups of ~(n/k) is optimal. Also liked D and E (don't really know why — maybe because I tried E in the past without success).

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

Double post, sorry (chrome ... )

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

В задаче С ответ возможен, когда k^d >= n? Если да, то поздравьте меня, я по ошибке возводил k в степень до d+1 и проверял на соответствие с n... >:c Ну если нет, то жду разбора

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

How to solve C ?

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

    there are K^D configuarations for any students becaue can choose any of the K busses on a given day and there are D days.

    so if N > K^D , one these configs will repeat.return -1 if this is true.

    Else think of how 4 digit binary no.s are arranged. - 0 0 0 0 - 0 0 0 1 - 0 0 1 0 - 0 0 1 1 - 0 1 0 0 - 0 1 0 1 - 0 1 1 0 - 0 1 1 1 - 1 0 0 0 - 1 0 0 1 - 1 0 1 0 - 1 0 1 1 - 1 1 0 0 - 1 1 0 1 - 1 1 1 0 - 1 1 1 1

    • Digit at place 0 have peiod of 1
    • Digit at place 1 have peiod of 2
    • Digit at place 2 have peiod of 4
    • Digit at place 3 have peiod of 8

    Note that thse places are analogous to days in our question and value of these place will be between 1 to K instead of 0 to 1

    Hope this helps.

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

    In short, before the first day you have the group of n students, and every day you break every group of g>=2 students in min(g,k) new groups. If g <= k, then each student gets its own bus, otherwise the group is split into k new groups of about (g/k) students.

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

    Okay, here's a full proof and stuffs. Shorter solutions are present above.

    Claim: If n > kd, then there's no solution.

    Proof: Induct on d. For d = 1, if n > k1 = k, then by Pigeonhole Principle, at least two students go to the same bus and they become good friends. Now suppose our claim is proven for d = i. To prove this for d = i + 1, we see that if we have n > ki + 1 students, by Pigeonhole Principle again ki + 1 students will go to the same bus on the first day, and we can invoke our induction hypothesis on these students for the remaining i days. Thus if n > kd, there's no solution.

    Claim: If n ≤ kd, then there is a solution.

    Observe all d-digit numbers in base k, including leading zeroes. (This means the numbers 000, 001, 010, 011, 100, 101, 110, 111 for k = 2, d = 3, and 00, 01, 02, 10, 11, 12, 20, 21, 22 for k = 3, d = 2, for example.) Since there are kd such numbers, we can assign each student to some number so no two students share a number. Now, on the i-th day, all students whose i-th digit (from either end, but let's suppose from the right) is j goes to bus j + 1. For example, with k = 2, d = 3, we have the students 000, 010, 100, 110 in bus 1 on day 1, and the students 010, 011, 110, 111 in bus 2 on day 2. This gives the required schedule.

    Now our task is to implement the above.

    Checking the first claim is simple; however, since kd can potentially go to (109)1000 = 109000 (over 9000...not), we need to handle some overflows. The easiest method is to declare a temporary variable tmp that is a 64-bit integer, initializing it to 1, then loop d times, multiplying k to tmp and comparing it with n. If after all d iterations we still have n > tmp, then there's no solution. Otherwise, at the first moment n ≤ tmp is true, the value of tmp is at most kn, since before this tmp < n is true and we multiply tmp by k. Since n ≤ 103, k ≤ 109, tmp ≤ kn ≤ 1012 fits in our 64-bit integer.

    Now, after we check this, we can start constructing our numbers. We can check the i-th digit from the right of a number j in base k in a simple way: (j / ki - 1) % k, with  /  being truncated division and % being modulo. This is true since dividing by ki - 1 means we're removing the last i - 1 digits, which makes the unit digit to be the i-th digit originally, and "modulo-ing" by k means we throw away all digits except the unit digit, so now we have the i-th digit alone.

    If we assign the numbers to the students consecutively starting from 00... 0 = 0, it becomes a simple iteration to find the bus numbers. For day i, iterate over j = 0, 1, ..., n - 1; find the i-th digit of j in base k, add by one (since the possible digits are from 0 to k - 1, but the buses are from 1 to k), and that's the bus number of the student.

    Here's my solution in C++, which should be rather straightforward.

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

    one can also use DFS to solve this problem.

    see my submission below for more information. The basic idea is to go through all permutations using for loops, and stopping when we have enough of them.

    http://mirror.codeforces.com/contest/459/submission/7470821

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

How to solve D?

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

Power of Codeforces!!
I'm seeing about 50 submissions that are being judged simultaneously.....!
wow....thanks a lot MikeMirzayanov

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

Today AK is crazy

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

Wasted precious time in problem A!

I focussed on the boundary cases and later saw that p1 and p2 were in [-100,100] while p3 and p4 were in [-1000,1000]. I misread first as [-1000,1000]...

Also, very fast systest! (Remember last time)

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

I tried to hack more solutions.At 9 of them I got this error: "FAIL Unexpected character #13, but ' ' expected (stdin) [validator Validator.exe returns exit code 3]" and invalid input.I really do not know why...the tests were like this: n 1 1 1 ... 1 I took care in don't having a space at the end of the string formed by 1.

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

Always this bug. sigh.

cout << ( (long long) (x * (x - 1) ) / 2 ) << endl;

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

In A I hacked one solution by silly test "1 5 5 1" :|

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

Congratulations, azizkhan!

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

Submission 7474163, I've tested on my llvm-g++. While running the data "625 5 4", it did not output "-1", but the right answer. While running on Codeforces server, it returned Wrong Answer.

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

What was the tricky test for problem E?

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

Editorials?

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

I have a question that we always ask! :D

When are the ratings going to be updated?

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

Why everyone who tried to solve the problem C by FPC got a TLE on the testcase 9?

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

yyfkiller3 registered 5 hours ago :(

Hopefully this is his real account

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

Problem E is almost the same as Codility's Magnesium 2014 challenge.

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

Wrong Answer: http://mirror.codeforces.com/contest/459/submission/7475559 Accepted: http://mirror.codeforces.com/contest/459/submission/7475581

Sorry guys, but it seems like a BUG in Codeforces. Those are the same, and there was no warning informing about the %ld issue (%Ld is also WA). I have no idea why this hasn't been fixed already, it has been around for a long time, but now Codeforces is not warning us about the replacement of %ld by %I64d anymore.

Thumbs down.

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

hi It's a very good contest.

I haven't seen theory of problem E ever.

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

Div.2 Problem B: http://mirror.codeforces.com/contest/459/submission/7476006 Why should the type of counter of flowers be long long? MAX_N = 10 ^ 5 which is integer. I saw many who solved this problem used long long instead of int. I got AC with that but I don't know why. Any help?

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

    Yo can have, for example 10⁵ 3s, and 10⁵ 4s, so 10⁵ * 10⁵ = 10¹⁰, so you needed long long

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

    The result (number of pairs) can be up to N*(N-1)/2

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

    The counter of flowers don't need to be long long, if you remember to cast the multiplication it_min->second * it_max->second to long long first. If both variables are ints, when you multiply the two, the result will still be an int and it might cause an overflow.

    After all, you can't do this to print 1018 due to overflow: int a = 1000000000; cout << a*a;. The same reason with why you can't do cout << it_min->second * it_max->second; without risking overflow.

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

      Ok but If I do this: cout << (long long) a*a; Does It cast the overflowed value?

      So my question is: When does casting be enough and when does making "a" long long be a must?

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

        cout << (long long) a*a; is enough, since the order is (long long) a first, before multiplied with a, so the result is stored as a long long and it won't overflow.

        Casting is enough if the variables don't overflow. For example, if a is an int, as long as you don't put anything greater than the maximum capacity (usually 231 - 1) to a it's enough. However, if you keep using (long long) a*a, (long long) a*b, (long long) a*BIG_NUMBER everywhere, consider to as well set a as long long to avoid casting all the time even if it doesn't store a large number. Faster (and cleaner) that way.

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

Hello all, could anyone please help me why this code is TLE on tc 31? 7470052

I really don't have idea what I'm doing wrong here :(

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

Who can explain me why in my solution http://mirror.codeforces.com/contest/459/submission/7464445 are wrong? On my own comp i have right answer on test #6 for this solution

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

Hello! I want to ask you is that the correct solution for the fifth task. We can use dynamic programming and the state will be the current node and the weight of the last edge. But it uses too much memory. The maximum number of edges is only 30000. Moreover an edge has the information for the current node and the weight and our state now will be only the last edge. Is that correct?

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

Я кстати правильно понимаю, что Е это баян? Потому что если нет, то как люди решали её за 6-7 минут?

As far as I understand, E is a well-known problem for top contestants of these round, because they solved it in 6-7 minutes, isn't it?

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

    You asked this question in english thread, so i'll respond in English

    I saw this problem 5 or 6 times during last year, most recently — 2 days ago at SNSS Round 1. BTW, i think that general idea "sort edges and then add them one by one" for this kind of problems is well-known, and one could come up with solution in short time even if he did not solved exact same problem before.

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

I initially forgot the contest and came in the middle, didn't look the scoring system is dynamic, found D easy and participated then solved A and B with very low points. Finally get WA on D because of overflow . I'm green again !!! :S

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

Hello guys, Please look on this sumbit: http://mirror.codeforces.com/contest/459/submission/7477151

v[MAXN] = (the biggest weight on path, path's length) Why, if I comment this if, I got WA on test 5? It looks to me unnecessary, since I find always the longest path (INF)?

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

Round was great one, although I solved only B and E. Problem A: Failed. Problem D: didn't have time. Problem C: I don't know solution.

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

I found a solution for problem E where we build a secondary graph with the edges of the original graph(G=(V,E)) as vertices, let's call it G'=(V',E'). Obviously |V'|=|E|. Now for each two vertices from V'- u and v, if there is an ascending path using the edges from the original graph that correspond to u and v, then we connect them(we build a directed edge from u to v).

For example: There is a directed edge from 1 to 2 with weight 4, and an edge from 2 to 3 with weight 6, then we connect the vertices that correspond these edges in G'.

The resulting graph is a DAG and we can use a simple BFS to find the longest path after using a topological sort. The only thing that I can't figure out is how to prove that G' is a DAG. I know the solution is O(M^2), the complexity can be easily reduced by not trying all the possible combinations of edges.

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

When editorial will be published?

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

problem c i think is too strict time limit, my submission tle in tc 9, which is 1000*1000 numbers needed to print

http://mirror.codeforces.com/contest/459/submission/7479926

i tried counting time needed to fill all output to array, just needed 12 ms, and in custom test it needs about 1600 ms until it finished running

edit : tried to add them all to StringBuffer first, then print in one line for each line got AC, i wonder printf from printwriter java is slower than println

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

    Yes, input/output is slow as heck. When there are a lot of things to read/write, this rules out many slow languages. Consider learning C++ or some fast language for this kind of problems with heavy I/O. (I mostly use Python, but I used C++ for this problem for this very reason; Python wouldn't be able to print 106 numbers in time.)

    As for your question added as an edit, I can't say, since I don't know Java much.

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

I have come up a solution of E with mlgm time. My approach is , first take the graph as edge list. Now for each edge we do a dfs(i.e DP) from that edges endpoint. and calculate the maximum path from that edge and save it in a map.

but this solution gets TLE. I tried unordered map hashing, but still TLE at case 6. Can someone explain why mlgn solution doesn't work? Here's my submission 7481958

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

Div.2 Problem C: http://mirror.codeforces.com/contest/459/submission/7482628 On test 3, d = 2 so the answer should be 2 lines not 3.

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

are you sure about meaning of "soon" ?

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

How do I do problem D using Segment Tree ?

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

Congratulations to all that solved all five problems! By the way, why did http://mirror.codeforces.com/contest/459/submission/7473140 fail test 45?

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

please add editorial soon

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

"Editorial will be published soon." = "Never."

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

Самую сложную задачу решили 500 человек и если хотя бы один человек написал разбор для этой же задачи, и остальные разборы написали другие люди, в итоге мы получим разбор одного раунда?

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

    Идея такая. Сортируем все ребра в порядке убывания. Для каждой вершины поддерживаем вектор двух чисел. А именно, вес и ответ, если начинать обход из данной вершины. Теперь идем по отсортированным ребрам. Для каждого ребра смотрим на вектор чисел вершины, в которую ребро входит. Бинпоиском подбираем позицию, в которой вес будет нас удовлетворять. Назовем пару найденных чисел W и ANS. Тогда для текущей вершины (вершина из которой исходит текущее ребро) пушим в вектор вес текущего ребра и max(ANS + 1, предыдущий ответ для этой вершины). Очевидно, что в этом векторе веса будут в убывающем порядке, а ответы в возрастающем, что позволяет при бинпоиске подбирать оптимальный "путь".

    P.S. Зачем было писать комментарий на русском в английскую ветку?

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

      Можно обойтись без бинпоиска, если просто поддерживать в вершине лучший ответ для двух различных весов исходящих рёбер.

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

Still waiting for the editorial... :/

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

Мне кажется, или таски отсортированы не по возрастанию сложности??

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

"soon" is up :D where is the editorial? Erfan.aa