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

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

Привет Codeforces!

Рад сообщить вам, что 7-го февраля 2017 в 20:05 МСК пройдет Codeforces Round #396 для участников из второго дивизиона. Как всегда, участники из первого дивизиона могут принять участие вне конкурса.

Раунд подготовлен мной и mohammedehab2002.

Хочу поблагодарить moaz123 за помощь в подготовке, zoooma13 за тестирование некоторых задач, KAN за помощь в подготовке раунда и за перевод условий на русский язык и MikeMirzayanov за прекрасные платформы Codeforces и Polygon.

Вам будут даны 5 задач и 2 часа на их решение.

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

UPD 500-1000-1500-2000-2500

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

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

A true Codeforces fan can not scroll down without upvoting this comment .

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

MikeMirzayanov mahmoudbadawy There is a bug with registration. Div1 users cant register unofficially.

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

Времена меняются... Надеюсь, к лучшему:)

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

Hope to be a good round. Good luck to all participants.

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

The email says the round will have 6 problems, but the post says 5. Which one is it?

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

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

is this the 1st Arabic official round on CF ??

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

mohammedehab2002 shares a name with an Egyptian weightlifting superstar. Guessing not the same guy but would be cool if so.

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

short blog :) I love it

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

Here's to clever yet easy problems! Hoping to become candidate master finally...

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

Rating != Knowledge
Even newbies can think of a beautiful problem, which can be challenging for masters!

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

Prepare by pupil?

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

I have short.

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

New authors often surprise CodeForces community (in good way)... Trust on interesting contest, good luck to all!)

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

New contest, new opportunities to learn and possibly get better. Thank you CodeForces

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

What a stupid contest

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

already got these hackers

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

belive it or not, this was the worst contest I have ever seen

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

I'll just leave this here...

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

Hi! I'm working on rating calculation tool. It's close to be ready! You could find this contest's rating prediction here. I hope chrome extension would be ready till next contest.

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

In B, we can write O(n^2) because maximum value of n for which answer is NO is ~90 ?

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

How to solve problem D? I could think of an approach using 2 dsu's. but did'nt code

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

    I used 1 dsu and an additional array of antonyms (if i-th and j-th sets are antonymical, ant[i]=j and ant[j] = i).

    You just have to update the sets_merge operation to handle antonyms: if you merge a and b, ant[a] and ant[b] should also be merged.

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

      how update and handle sets in this case?

      1  aba aca
      1  ada aea
      1  afa aga
      2  afa aea
      
      • »
        »
        »
        »
        9 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +3 Проголосовать: не нравится

        you have to think this way:

        2 strings are synonims.you do a union operation on them.but what happends if one of them or both have an antonym?

        if they both have one,you unite their antonyms.if only one has,you make sure that the root knows who's that antonym. if they are antonyms you update the antonyms array.but,there are again subcases

        let's say the words are a and b if a had an antonym,then b and ant[a] are synonyms,so you unite them if b had an antonym,then a and ant[b] are synonims. again,be carefull that the root always knows who is his antonym

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

    Yes it can be solved using dsu, you just need to color the verticles (the words) and find the answer for each query

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

    You can use 2 nodes for a single node. The new graph will have 2*N nodes. For synonyms, add edge between (u,v) and (u', v'). For antonyms, add edge between (u, v') and (v, u'). Use DSU.

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

Can someone explain C? I thought it was DP but I couldn't figure out how to put it together.

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

I loved D. Thanks for a great contest.

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

Lost a lot of points on C, because I thought there should be at least one cut :/

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

with 10 more minutes I would have finished debugging D and solved all problems. :(
contest is much easier than usual

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

Awesome problemset! Devoted my whole time in solving E but couldn't. If there would have been integers attached with edges instead of nodes then it was quite easily solvable but this little twist made the contest complete fun for me. Thanks !

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

Can someone give an idea for D?

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

    While adding pairs, you can use disjoint-set union to see if the words are already associated with the same meaning (be it antonymous or synonymous). Ignore those edges when adding them. Run DFS for each component, coloring its synonyms white and antonyms black. Then you can answer the queries (of both kind)

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

Problem D is here Link However without the part of answering some queries on relations.

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

Just a couple of minutes more and I would've solved D. It's nice to spend the entire contest on C and realize that D is solvable when you have only 15 mins left... Thanks for the contest, anyway.

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

Русский перевод очень плохо (.

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

Can i see some hack cases for 'A' that you people used. I tried hacking, but failed. Thanks

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

For problem B, what should be the hack case for O(n^3) solution which didn't use sorting?

Update: This is a hack case for O(n^3): 100000 1 2 3 4 5 6 7 8 9 .......... 100000

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

How can this user, r_clover, solve both problem B and D within a minute?

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

So, Codeforces started copying problem from UVa :\ :\ :P

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

ОБРАТИТЕ ВНИМАНИЕ

Я хотел смешно пошутить, но нашёл кое-что, что меня возмутило. По этой ссылке вы можете увидеть, как человек опубликовал своё решение по одной из задач 108 минут назад, то есть прямо во время контеста. Думаю, его следует наказать. Ставьте ПЛЮСИКИ, подписывайтесь на мой блог. UPD Его забанили, всё хорошо, спасибо

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

That moment when you failed both C and E only because of wrong answer on n = 1 case...

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

Did anyone else failed system test on test 22 on problem C.

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

Thanks for this good contest .

I really like these problems.

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

Why codeforces div2 contests are becoming easy?

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

guys this guy i tried to hack his code for A

by test case

abc xyz

but it's weird that it was unsuccessful attempt ?

his code :

s=input() t=input() if s in t: if len(s)==len(t): print(-1) else: print (abs(len(s)-len(t))) elif t in s: if len(s)==len(t): print(-1) else: print (abs(len(s)-len(t)))
else: if len(s) > len(t): print(len(s)) else: print(len(t))

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

    The code works perfectly for your case. It is because your case belongs to the third condition (the else: line)

    As if s in t: in Python means checking if the string s is a substring of t, while in your case, abc is not a substring of xyz, so s in t returns FALSE in your case. And same for the t in s condition as well.

    As a result, the code goes here:

        if len(s) > len(t): print(len(s))
        else:               print(len(t))
    

    And thus, print 3 as the output, which is the correct answer.

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

Interesting thing about problem B is that stupid solution which uses random works fine and passes all tests. Solution: 24513380

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

    It's not so stupid. If n > 50 then you can always find such triangle so chance of finding one randomly is high. In other hand when n <= 50, randoming is pretty much like using n^3 brute force, so as I said it's not a dumb solution.

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

Div2 C, rip to all of those who got WA on test 36

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

Will be editorial?

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

I implemented B in a little bit bad way, I used 3 for loops but the third one is redundant then also time complexity of my solution is O(n^2). After locking and seeing other solutions I thought that my solution can be hacked by giving tle but it indeed passed the system testing. But by intuition it was clear that finding such a test case was difficult, so I wanted to know whether it is possible to hack my solution with certain sequence or not ? and how did it passed the system test . http://mirror.codeforces.com/contest/766/submission/24497421

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

I got time run exception for solution of second qn written in python. after rewriting it in C++; It I passed it. What does it mean?

n = input()
C= map(int,raw_input().split())
C.sort()
flag = False
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if C[i]+C[j]>C[k] and C[i]+C[k]>C[j] and C[k]+C[j]>C[i]:
        flag = True
        break
print "YES" if flag else "NO" 
»
9 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I know I'm a little late, I had to work yesterday :(

Problem D is exactly this problem (with different input/output format obviously)

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1099

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

I have calculated the complexity the code to be NlogN*maxl +MlogN*maxl+2*Mlog+N*logN+Q similar to the question authors (N+M+Q)logN*maxL, but getting TLE on test 13 please somebody can review my code. I know I havn't run the dfs from root node but this should pass too. please help!

http://ideone.com/EhwB7S

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

Hey guys. How to solve E? I can't get this prob.