**Let's discuss the problems.**

Reminder: in case of any technical issues, you can use lightweight websites
m1.codeforces.com,
m2.codeforces.com or
m3.codeforces.com
×

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

1 | tourist | 3698 |

2 | Um_nik | 3463 |

3 | Petr | 3341 |

4 | wxhtxdy | 3329 |

5 | LHiC | 3300 |

6 | ecnerwala | 3285 |

7 | sunset | 3278 |

8 | V--o_o--V | 3275 |

9 | Benq | 3262 |

10 | mnbvmar | 3248 |

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

1 | Radewoosh | 187 |

2 | Errichto | 180 |

3 | rng_58 | 161 |

4 | PikMike | 160 |

5 | Vovuh | 157 |

5 | Petr | 157 |

7 | 300iq | 151 |

8 | Ashishgup | 149 |

9 | majk | 148 |

10 | Swistakk | 147 |

**Let's discuss the problems.**

↑

↓

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/26/2019 17:43:58 (e3).

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?