**Let's discuss the problems.**

Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official.
×

# | User | Rating |
---|---|---|

1 | tourist | 3469 |

2 | Radewoosh | 3357 |

3 | OO0OOO00O0OOO0O0…O | 3264 |

4 | LHiC | 3227 |

5 | ksun48 | 3184 |

6 | scott_wu | 3168 |

7 | Um_nik | 3166 |

8 | CongLingDanPaiSh…5 | 3157 |

9 | Petr | 3139 |

10 | V--o_o--V | 3135 |

# | User | Contrib. |
---|---|---|

1 | Radewoosh | 195 |

2 | Errichto | 175 |

3 | rng_58 | 158 |

4 | Ashishgup | 157 |

4 | neal | 157 |

6 | tourist | 154 |

7 | PikMike | 152 |

8 | Petr | 151 |

9 | Um_nik | 149 |

10 | kostka | 148 |

**Let's discuss the problems.**

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/18/2018 15:13:15 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

Auto comment: topic has been updated by Hunter_Gon (previous revision, new revision, compare).Auto comment: topic has been updated by Hunter_Gon (previous revision, new revision, compare).How to solve C, D, H, J.

If this contest has a time limit, Problem C is very interesting

Is there any time limit?

Yes, Time limit — 2s.

Problem CLet

xbe the number which has odd number of odd divisors. Through observation, you can find that , wheree_{i}is even. In this configuration, total number of odd divisors will be . In other words, we are looking forx= 2^{w}×y, whereyis a perfect square number.You should solve the problem for range [1,

N], and print solution of range [1,R] minus solution of range [1,L- 1]. To solve for [1,N], you should iterate for all possible power of 2. For eachk, add .Problem DFirstly design a function

f(n), which returns the highest number which is smaller thann, and has the digits allowed in the problem statement. This can be easily done with greedy observations.You can now start with input

N, and iterate by settingN=f(N) each time. Stop this iteration and print the answer, when currentNis prime. Use Miller-Rabin for primality testing. I don't know the proof why a prime number with the given definition can be found with small number of iterations. We went with intuition. If anyone can prove it, then please share it here.Problem HTrivial dynamic programming solution. States: idx, lastColor.

Problem JYou can always make the longest possible path in the answer graph equal to 1. Make the tree rooted. Toggle the direction of edges in consecutive levels to face different directions. Let's say

u-vbe an edge, whereuis at leveli. Set the direction of the edge fromutov. Now, letv-wbe an edge, wherevis at (i+ 1)^{th}level, Here set the direction fromwtov.Thanks bhaai.

And will the problem set be added to gym?

Lol. I don't know anything about it. I was a participant in this contest.

And if it is possible, can you please write an editorial for other problems too? It would be great for us.

oo

For problem D: here

Where I can submit?

What about problem D?

Our team got AC on problem C in a O(1) solution.

Check prophet_ov_darkness's comment.

What is the O(1) solution for C?

The numbers to count have even power of odd primes. They can or can't have even power of even prime, 2. So, the number of numbers those are either square or double of a square counts. But precision is an issue that was to be solved.

How did you solve the precision error?

We got Wrong Answer for precision error while calculating square root of a number. So instead my teammate did binary search to calculate square root.

Also you can use sqrt((double) value); This is called typecasting. Really important issue.

for problem G — is it possible to solve it in less than o(10^8).. 10^8 will get TLE I think. if it possible to solve it in less complexity pls share your idea

Many people solved it in that way, they got AC.

how to approach the problem I (Vugol search)????

We solved it using trie.

For any query, note that we can do any of the following.

`lcp+smartness`

`lcp`

For the latter, keep a trie using all the words from the database. Now traverse for the query word and take the maximum lcp.

For the first part, find out which strings in database are anagrams of each other. You can partition them into components by simply sorting the characters of those strings. Now for each such component i.e. the strings which are anagrams of each other, make a trie consisting of the database words. Find out which query words are anagrams of these strings. Traverse the trie and try to maximize the results by a rmq-similar approach.

How to solve E?

This should help: #

can u briefly explain the approach of finding anagrams from the trie plz?

We can internally sort the strings. Like "me" becomes "em". Now the strings with the same sorted outcome are anagrams of each other. Build a trie using those strings. Similarly find out which query strings have the same sorted outcome i.e. anagrams of these strings. For those queries, traverse the trie and update the maximum value if possible.

I tried to draw something: (Not exactly sure if it helps. I am bad at explaining things, I guess.)

( If the image doesn't show: https://pasteboard.co/HHl76cI.jpg )

tnx a lot :). And u are good enough to explain something :)

How did you solve F (find the substrings)?

We calculated the number of distinct sub-strings for every length upto |s| using suffix array. Then it got pretty easy. We had d_i as the number of distinct substrings of length i, the result is summation of (26^i — d_i) for every i from n to m. mochow did it. :3

does anyone have the problem set of onsite dhaka regional?