Задача A. Кнопочные гонки
Задача B. Число на доске
Задача C. Звёздное небо
Задача D. Палиндромная характеристика
Задача E. Игра пингвина
Задача F. Дороги в королевстве
№ | Пользователь | Рейтинг |
---|---|---|
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 |
Название |
---|
I did a O(nclogX + QlogX) solution for problem C. Where X is the maximum coordinate. Answering each query in O(log X).
del
For problem C ,what I am doing is storing the cummlative sum of the value of all stars in a row x upto y at time instant t as cum[x][y][t] for all t<=10 and then for each query I am running a loop for i= x1 to x2 and adding cum[i][y2][t]-cum[i][y1-1][t] to the answer where t=t mod (c+1) .I am getting WA.Can anyone please help? code link : http://mirror.codeforces.com/contest/835/submission/29068753
two stars may have the same x,y
Hi! In problem C I tried to do a Brute force solution with some optimization but getting WA for TEST 3. Can someone please look at my code. http://mirror.codeforces.com/contest/835/submission/29078375
You must have ignored the possibility of having two or more star at one point.
See carefully constraint for number of stars (10^5) is more than the grid (100*100)
Does this mean that the right half of
abba
is actuallyab
notba
? I was solving it as if the right half wasba
.It is
ba
.I had a huge thing misunderstood during the contest, thanks for clarifying.
So the condition was supposed to be "the left half is the reverse of the right half"? or am I understanding something wrong?
I don't think you're right. In the statement: "Its left half equals to its right half", and this is the tricky part.
No, it wasn't. But we can prove that it is.
Let's prove that k-palindrome (k >= 1) is palindrome. k = 1 is by definition. k >= 2: s = t + c + t, where t is (k — 1)-palindrome and c is some character or empty string. s is k-palindrome. So, t is (k — 1) palindrome. And we know that t is palindrome. So, reversed(t) = t. And s = t + c + reversed(t) and it is palindrome.
Yeah the editorials for even other contests should be posted fast like this one! :)
Sorry for my poor English:) Can anyone explain problem B, forth test, i tried to think on it but my answer is also wrong, help me!!! UPD: I FINNALY UNDERSTOOD MY MISTAKE :D
Hello!For problem C.I looked through questions of contestants and my question is quite similar to those. I just can't understand why i got WA on 3 Test. I took into account case, when stars are in one spot, but it didn't help me. It will great help to me if someone will find bug in my code: http://mirror.codeforces.com/contest/835/submission/29064634
It will be great help*
Задачу D можно решить с помощью рекурсии с запоминанием, вот код: http://mirror.codeforces.com/contest/835/submission/29073244
For problem C, what I did was storing the brightness of stars in the array and accumulating the (brightness + t) % (maxBrightness+1) inside a given rectangle. Suppose maximum brightness is 4 and the query is (1,1,1,2,2).
The brightness of stars are stored in a following manner:
0 0 0 0
0 1 2 0
0 0 0 0
I am checking from (1,1) to (2,2) and and it produces: (1+a[1][1]) % 4 + (1+ a[2][1]) % 4 = 3 What seems to be a prolbem?
I would appreciate if someone point out the logical defect on the idea. http://mirror.codeforces.com/contest/835/submission/29073973
There can be multiple stars at a point. Also, it seems that you are looping through the rectangle of each view, which might be too many operations to fit in the time limit.
In D we should make m = [(l+r)/2]-1 only if length of substring is odd, otherwise m= [(l+r)/2]; By the way, how to use special symbols? like [ ]?
For problem C,I have a question:why sorting x and y,then lowbound and upperbound their rang ,but test3 was so strong,that I can't find my error..I need help http://mirror.codeforces.com/contest/835/submission/29072180
Can someone explain what is bad with input/output in my solution of E?29084972
You need to flush the output every time you print. Some languages back up all printing operations into a buffer until there's enough (because printing takes time, so printing a single large string is faster than many small strings). This makes the grader to not be able to see your output; flushing forces the language to actually print it out to the output no matter whether the buffer is full or not. It's also written in the problem statement.
Nope, it doesnt help (in java println workes like flust). I tried to use flush after every print and only after printlns, nothing helps. I dont get where is mb mistake...
Proof that 19 questions is necessary for E:
At the worst case, n = 1000, so there are possible answers. You need to find the single correct answer. Each question you ask will give 2 possibilities, so k questions will give 2k possibilities. Of course, you need 2k ≥ 499500, otherwise some answers to the questions will have lump multiple possibilities together. Thus k ≥ 19.
For Problem D, I found a simple solution using Palindromic Tree, which runs in O(|s|) time and uses only O(|s|) memory.29085544
In fact I found this problem quite similar to another Codechef problem Here, but in this problem the range of |s| is much smaller.
Do you mind explaining your panlindromic tree solution?
It's hard to explain the whole idea of palindromic tree here, this tutorial may be useful.
First let's define the palindromeness of a palindrome S as the maximum k that S is k-palindrome. In this problem, actually we need to calculate the palindromeness and the number of occurrences for each palindrome.
The second problem is a basic application of palindromic tree which can be found in the blog above. To deal with the second one, for each palindrome S we need to know the longest palindrome prefix P whose length doesn't exceed , the palindromeness of S equals to the palindromeness of P + 1 if . It equals to 1 otherwise.
So the only remaining problem is to find P for each palindrome. And it's easy to cope with that with similar method of calculating the longest prefix palindrome. You can take a look at my code (where half[S] presents P) for more details.
Sorry for my poor English, hope you can get what I mean.
I know my code for D is not very efficient, but after testing 5000 'a's in custom test and it runs under 2800ms, I decided to submit it. But it gets TLE on test 30. However I submitted the exact same code after contest it passed. Does anyone knows the reason? Thanks.
Code in contest: 29067565 Code after contest: 29086375
You could write to jury. May be technique dependence.
Excuse me, what wrong or impolite did I say?
Here is a trap in Problem C: There maybe two stars with the same pos! I got WA for many times because of this!
its kinda obvious that there are . since there can be 1e5 stars but there are a maximum of 100 * 100 positions possible for them
OK.I'm sorry. Maybe I'm too weak
haha I wasted 2 hs because of that detail
im sorry i didnt mean that
I was wondering if problem C could be done using convex hull? Can somebody please explain why not and if yes then how.
Your queries are rectangles so it doesn't make any sense to use convex hull.
D можно решить с O(|s|) по памяти и O(|s|2) по времени хешами
29093349
Хэши в этой задаче совсем не нужны. Все предпосчёты, если они вам нужны, можно сделать за O(|s|2).
Looking For recursive solution For Problem D..
my code
Finally done by recursive implementation...check For reference
For problem D, would anyone like to prove OBS1? i know it's kind of obvious but i still wonder why :L
I explained it this way: divide our palindrome into 2 halves, while they are identical, i.e. abacaba <- aba <- a. Length of this chain is k, every member in it can be represented as 1-palindrome, so our initial string can be [1..k]-palindrome. (if we assign aba as 1-palindrome, abacaba would be 2-palindrome, if we assign a as 1-palindrome, abacaba would be 3-palindrome)
By induction, just assume that for any n <= k, n-palindrome is a 1-palindrome, then prove it for n = k + 1. So, let's take (k + 1)-palindrome, left and right halves of it must be same k-palindromes, which are 1-palindromes by our inductive assumption, thus the whole (k + 1)-palindrome is also 1-palindrome.
but whole k + 1 palindrome is also 1 palindrome doesn't prove k palindrome is k - 1 straightforwardly,right?
Oh, sorry, I incorrectly understood OBS1, my bad:)
Ok then, just change the assumption, now by the assumption for any 1 < n <= k n-palindrome is (n — 1)-palindrome, too. The prove will be the same, the only thing to deal with is the base case for k = 2.
We can prove by induction on k
Theorem: if s is k-palindrome, s is also (k — 1) palindrome, k > 1, |s| > 1.
Case |s| = 1, it's 1-palindrome = palindrome, since there's no definition of a 0-palindrome, there's nothing to prove.
Base case for induction: k = 2.
If s is 2-palindrome, s can be written as s' + c + s', s' is 1-palindrome, c is some character, possibly the empty character. Since s' is palindrome, s' + c + s' is also a palindrome, so every string which is 2-palindrome is also a 1-palindrome.
Induction hypothesis: Every string s which is k-palindrome is also (k — 1) palindrome, |s| > 1, |k| > 2. The hypothesis is recursive until k = 2.
s is k-palindrome so it can be written as [k — 1] + c + [k — 1], where [x] denotes some string which is x-palindrome.
Induction step: Let t be a (k + 1)-palindrome string.
t = [k] + c + [k], c is some character, possibly the empty character (check above the meaning of the [k] notation). Our induction hypothesis says that a string [k] is also (k — 1)-palindrome, so we can replace [k] by [k — 1], so:
t = [k] + c + [k]
t = [k — 1] + c + [k — 1]
A string is k-palindrome if can be written as [k — 1] + c + [k — 1], we just wrote t as this way so t is k-palindrome and the induction is finished.
In Problem D,I thought of the solution above. However, I am afraid of the time limit because dp costs O(|s|^2) time and we must compare the string to make sure it's a palindrome, so I think the time is more than O(|s|^2), is this true?
After understanding the solution c++ code,I understand. Just ignore,please. I can use the result before to decrease much time complexity.
I do not understand the description of problem D clearly.
how is the answer for 2nd sample test case calculated?
abacaba
=>12 4 1 0 0 0 0
thanks in advance :)
If a string is K-palindromic it will be (K-1)-palindromic as well. That means that for a[1] = 12 we count every possible palindromic string. You can check that there are exist 12 palindromic strings. a[3] = 1 because only abacaba is 3-palindromic string. a[2] = 4, because {aba, aca, aba(2nd time)} are palindromic string but don't forget to add {abacaba} as well because it is 3-palindromic so it is 2-palindromic too. So a simple solution is to find the a[i] table and after do that operation a[i-1] += a[i].
Problem E
Really interested to know how to prove such a lower bound! :D
You can read the proof here: http://mirror.codeforces.com/blog/entry/53588?#comment-376471
In problem D, why hashing TLE? I think the complexity of my solution is O(n^2 * log(n)) which is very small (correct me if I'm wrong) .
My submission: http://mirror.codeforces.com/contest/835/submission/29868893
Can anyone help me?
Hashes are slow. The constant factor of your solution is too large.
The intended solution is O(n2) and you don't need hashing in it.
Can anyone please see my code for problem C? I am getting TLE on test 8. This is my code Please help me.
your code complexity is n*q which will exceed time limit
Problem F has almost exactly the same model as CF-515-E, and can be easily cheesed using a segment tree.
https://mirror.codeforces.com/contest/835/submission/197225410
(note to self: write explanation later)