Let's discuss the problems.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Let's discuss the problems.
Название |
---|
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 C
Let x be the number which has odd number of odd divisors. Through observation, you can find that , where ei is even. In this configuration, total number of odd divisors will be . In other words, we are looking for x = 2w × y, where y is 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 each k, add .
Problem D
Firstly design a function f(n), which returns the highest number which is smaller than n, 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 setting N = f(N) each time. Stop this iteration and print the answer, when current N is 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 H
Trivial dynamic programming solution. States: idx, lastColor.
Problem J
You 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 - v be an edge, where u is at level i. Set the direction of the edge from u to v. Now, let v - w be an edge, where v is at (i + 1)th level, Here set the direction from w to v.
And will the problem set be added to gym?
Lol. I don't know anything about it. I was a participant in this contest.
For problem D: here
Where I can submit?
https://algo.codemarshal.org/contests/icpc-dhaka-preli-18
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.
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?
https://algo.codemarshal.org/contests/icpc-dhaka-18
You can submit also