Recent actions

Why my output for large inputs coming 0 for question C ?

Created or updated the text

Solved,Thank you!

You made well-known mistake: Arrays.sort() -> Collections.sort(). Sort in Arrays has O(n^2) in worst case.

You're welcome ;D

Same issue!

Same issue

In Question C,I had got time limit exceed in test case 19 in java while with same algorithm (same code) in C++ is able to pass all test cases.

For fun.

Most people also do the problems in order because they expect them to be in order of difficulty.

Thank you very much ! I ever never know :D

Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).

To educate others :D

then why do Div1 participate in Div2/ Div3 or Educational rounds?

ideone is by default public. you can see submissions in Maybe someone copied from there. keep your submissions private from now on. Its an incognito type icon near stdin below input text box.

Where is the editorial ?

Yeah figured it out. Thanks for the help :)

__i use ideone to run the code but the solution is copied and i get unrate. Does my computer have malicious code? Explain me, please.

Thanks for div2 only contests !11!1

How could i optimize my submission which got TLE on 68the case ?


When will you upload Editorial??

Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).

Thanks for the help Jiburiru

only use long double when you dont need accurate number

I am getting WA using long double...I am pretty sure it's due to floating errors.38530049..Please help

then what's the fun of hacking other's solution

Is there any solution for F except O(N * 26)?

In educational rounds, No.

In last box there are at least k pencils so we have to find rightmost j that
j <= d — k and dp[j] = 1 now check that pencils j + 1 to i can be in one box or not?

It works like this:

First we replace each letter in S with the distance to the nearest same letter on the right, or ∞ if there's no such letter. E.g. "abacaba" becomes [2, 4, 2, ∞, 2, ∞, ∞]. This takes O(n) time. Now instead of a sequence of letters, we have ≤26 interleaved linked lists — one for each letter type in S.

If substrings X and Y are isomorphic, then all elements of linked lists that form X must be identical to those which form Y, except the last elements, since they point outside our region of interest.

Therefore, X and Y are non-isomorphic, iff there is an index i, s.t. X[i] != Y[i] && (X[i]+i < len(X) || Y[i]+i < len(Y)). To find i, we quickly (using a lcp array) iterate over all j, X[j] != Y[j] and check X[j]+j < len(X) || Y[j]+j < len(Y). We will do at most 26 iterations, because X[j]+j >= len(X) means that j was the last occurrence of the letter at j.

does hacking a solution not effect our rating

UR?My Rating was changed a few minute ago.

Why not wait 10 more minutes and then discuss whether it is rated?


I tried to hack solutions of rolling hash of 2 const modulo after waking up, but the contest had finished.

To hack rolling hash by 1 const modulo is very easy by birthday attack.

is this contest really unrated.

The rating were changed so it's rated

when will the editorials be updated?

The test case was fixed after 45min the contest started(and affected some verdict).

I think some contestants waste the time because of the issue, so it's good that this contest change to unrated (or semi-rated).

so it's unrated? but Problem E's tests are right?

Issue of the writer's solution was wrong on Problem E

(And not clear words on Problem D?)

why not rated?

To make it more clear — maybe it wasn't understood for the first time.

If there were no issues, that would have been my fault 100%. However in this particular case, my decision was biased by the bug in writer's solution.

I also think that it might be the case with more people as the difference in accepted solutions between D and E is very small, while it should be something like 250 for D and 450 for E, but I guess that many more competitors jumped to D as they saw that nobody was able to solve E for almost an hour.

Fix my code to use STL sort, I got AC. thank you! 38527514

Use inbuilt STL sort — sort(ar,ar+n) where ar ->array and n->size of the array.

Oh... I understand thx

How to fix it?

qsort has worst case O(n^2) I think.

maybe it's magic..hah

System test has finished,so is it rated?

get it. thank you.


maybe you are right. modified code got ac...thanks...but i still can't understand why i got a different result

Problem C:Why I got TLE Verdict?38494646

I didn't use while() so there are some troubles on sort?

If you mean On after sort, it can use deque to maintain dp arrays .

emmm.. I think your code "if(n-que.front().w<k)" has a little bug. if the queue is empty, then your code will runtime error?

Submit with diagnostics. Perhaps you have some undefined behavior due to the overflow or memory access.


As a novice, I have a question for everyone. Why did I submit the same code twice, but one got AC, another got WA. 38509969 during the game. 38524984 after the game

you can use radix sort. but i meant O(n) algorithm after sort.

This is the first time I know that it looks so magical. Thank you very much for your reply.

Don't write hashes modulo 2^64 link
The string in 16's test is Thue–Morse sequence


Can anyone tell me Problem F why my solution get WA on test 16's 9259th query? I have been debugging for more than five hours. qaq. this is my submission code: 38512729

Why are you taking x = d[i — k]? Can you elaborate more on that?
UPD : Got it NVM.

I don't think there is

first sort all numbers, now you just need to group consecutive elements, we can use dp to solve this problem. Let dp[i] indicate whether the first i elements can be successfully grouped, dp[i] is transferred by dp[l] | dp[l + 1] | ... | dp[r — 1] | dp[r]. l, r is the interval endpoint that makes dp[i] exactly satisfy condition, As i increases, l increase, r increase, so you can use deque to maintain.

For problem F,if the size of alphabet is up to 10^5 or larger and other constraints remain the same,is there any approach to solve it?

Is it possible to do it without sorting the array at all then ?

We can hashes subscripts for each letter within each query range.

Problem D is similar to SRM 721 Div1 Easy.

Educational rounds are rated for users with rating below 2100, but it doesn't mean other users are unofficial. I think, In those rounds all users are welcome to participate officialy.

In contests page, the hacking phase for this round seems to be for 12 hours rather than a day.

Hi, I just wanted to mention that it seems that users with rating above 2100 are registered as official contestants... or at least they don't disappear when I unset the "show unofficial" checkbox.

Hope that doesn't causes any problem.

The error is caused in this line:

while(cnt && abs( *(s.rbegin()) - *L ) > l )

You are trying to access to the value pointed by L, but a few lines before, you erased that value from the set. I saved *L in a variable before deleting it from the set, and the Runtime Error was gone, but now it gives Wrong Answer. I'm not really sure what's the idea behind your code, so I can't help you with that. I hope this comment helps you solving the problem :)

PD: there is another error in that line: you forgot to check that the multiset is not empty before trying to erase an element from it. That may cause Runtime Error too. Bye!

maybe the number of a【i】will exceed n-1

No problem, it happens :D

Yeah, I just saw that.

Thanks. Sorry for bothering.

It's my fault. TIM_20180519215120

Actually, you output 2e+009 instead of 1999999999. Maybe this was the problem, not the precision of calculations?



No, not that, I said I avoid long long mutiplications.

I got WA using ceill(n/X) but AC (preliminary) using following code:

for(; n>0; n -= X, ++Ans);

I don't think it is wrong using ceill(n/X).

If you have to multiply numbers that big then you are doing something wrong? I mean, use long double as much as you want to if you are sure in the correctness of the answer you get. Or you can think a bit more and get a much smaller estimation on the borders of binary search.

I pass it using long double...(after contest q_q)

Thanks for replying.

We had a solution and didn't really want it too pass. It's like one step easier than the intended one.

OK, then I have no problem with D's limit.

All calculations in my solution are performed using only integer types and fit into long long.

So, you mean that long double is intended to fail ? Should "using long long instead of long double" be a part of the contest ? Maybe it should be but I don't know ?

Really, worst time ever : getting WA on test 7 but the logic of the program is absolutely right, struggling whether to submit again or to give up.

We had a solution and didn't really want it to pass. It's like one step easier than the intended one.

All calculations in my solution are performed using only integer types and fit into long long.

UPD: My fault... See comments below.

Well, it is a good round ... but problem D. (No offensive).

Even though problem D itself is a good one, but it is not very friendly to the CPPers.

We need to handle two long long multiplication carefully. ( Aha! I know it! I avoid this! )

And then math functions bring floating errors! ( WHAT? TIM_20180519215120)

Should "handling floating errors" really be the part of the contest?

My key point is : D is a good problem, but it shouldn't make certain languages better than others.

(Making D's limit into 109 would be a better choice, I don't know any brute force that can pass 109 but not 1018).


If 1 is your h1, meaning that it is the pillar that is leaning against the fence, then the other side has to descend from 5 to 1. It can't just stop at 5 abruptly.

Nah, it was so standard.

I got 5 wrong submissions because of this. Luckily I realized it during the contest. Misreading statements is one of my specialties.

I checked more precisely. At the time I was looking at the next task (after solving C), there should have been 23 E solutions accepted already, this was the last one:

At the same time there was 0 accepted solutions to E and there were 11 accepted solutions to D, the last one:

I have no reason to lie, as I said I expect a positive rating change. If I had seen these numbers when I was making a decision I would have started with E.

I just have a feeling that the issue with E is sufficient to make this contest unrated. I was impacted indirectly but many people were impacted directly.

Besides — there was incorrect author's solution, this fact should make the whole round unrated, given ACM rules. I object to policy of making rounds rated just to please the maximum number of people. Rounds should be unrated unless they ran perfectly in 100%.

What do you think MikeMirzayanov?

Okay, then why the answer to the case 20 4 be not 6? here 1 2 3 4 5 5 = 30.

wow ._.

I have time, but unfortunately, I lack patience.

I came up with this algorithm:

Let's call a vertex heavy if it has degree >= sqrt(M).

Let's call a triangle heavy if it contains at least one heavy vertex.

  1. We can count the light triangles as follows: Iterate over all edges (u,v) were both u and v are light. Now for every light vertex w adjacent to u, check if (w,v) exists in the graph.

  2. For heavy triangles, let's iterate over every heavy vertex u, and mark its adjacent vertices as visited. Now for every edge of the graph check if it has both of its endpoints visited.

can anyone help with a good test case for problem E ? cannot Figure out where it could go wrong. #noob

If you have time, you can just wait for editorial.

It is not an excuse as I will probably get positive rating change after this contest (at least this was my knowledge when writing this post)... And I'd rather give it up for unrated round as I feel that this contest was interrupted by the bug.

It just demonstrates the subtle impact of the issue. I based my decision on the number of problems solved and I got stuck on D until the end of the contest and I have a reason to believe it would not have been the case, but for the mistake.

As regards previous comment — it is not true. After 40 minutes I should have seen comparable number of solutions to both problems. If I see around 30 solutions on D and 0 on E, it is a clear indicator for me that D should be easier than E (not everyone should follow this logic).

I firstly calculated the max height I can reach such that I have enough sand bags to come down, then I calculated how many sand bags are left from reaching that height and then coming down to the ground . After that I calculated the length of the plateau by diving the remaining bags with max height and if now there is some remaining bag , I just increase the answer by one because that can be compensated by a dual move of that height when we reach that height while coming down. We can prove that it will always be equal to one of the coming down heights.