Comments
for(int i = 0; i < strlen(s); ++i)

is not a good idea.
This cycle has O(n^2) complexity.

Another solution of problem D. We use sweep line with events {segment_start, segment_end}. When segment starts we increase arr[pos_l]++, and when segment ends we decrease arr[pos_l]--. To find the answer, we need to check the k-th left-started segment in our array, each time for every event. If we are in pos and have segments_cnt >= k, we know that each of them has end-point >= pos, so our goal is to find k longest segments and answer is pos — po_l[k-th segment]+1. To implement arr[] we can use sparse segment tree. Code
Complexity is O(NlogN + Nlog109)

PS. Is it right complexity in editorial? Should it be O(NlogN + NlogR)?

Why does javacoder submit c++ solution?

Another (more complex) idea of problem E.
Sort all values, than calculate res[i] — answer for videocardi like leader.

N = a * b, so that
We iterate over videocards and want to do no more than operation per one. There are two cases:
1) Current videocard is leader. We assign xi like a and try .
2) Current videocard isn't leader. We assign xi like N and want to add xi to some leader videocard, where . So try
There is basic idea. You can check my solution for more details or ask me

On stouldDisconnects, 10 years ago
+7

Especially before submit during rated contest :)

+3

Same story about problem C. Solution was correct, but final cycle to find minimum value from last colors was from 1 to n instead of m.

Even for magic, 'cos 300^4 is 81*10^8

It's a good question :D But TLE on 16 pretest

Segment tree on each row to find minimal value

I wrote solution in O(n*m*n*log(m)). But it's not fast enough :(

if(a < b) answer isn't zero.

For example, 5!/6!(mod 1e9+7) = 36166666920

How to build segtree in O(n) time?

UPD. Yes, O(4*N) = O(N). My mistake.

In worst case, unordered map works in O(N) time, when ordered has O(logN).

On MikeMirzayanovCodeforces Round 350, 10 years ago
+9

How to pass test 4 in problem F? Easy problem, but I can't find bug in my code :(

It's not necessary to compress values of time. Check this solution.

Also in problem E we can create map <int, SegmentTree>, where segment tree is sparse (indexes as time and values as{-1, 0, 1}). If we have query "add/delete value x in time t", we just update tree x in position t by value 1/-1. And "count query x in time t" will be sum of tree x in segment [1,t]. Code.

try 4 4 answer is 0

Rating is calculated considering time of solving and first successful attempt. And also with some special expected and real positions. To more information click in this link.

My solution without "-1" case was accepted on pretests. Final sequence always exists.

On ZhNVCodeforces Round #324 (Div. 2), 11 years ago
-84

It's a part of problem! You must have good English skills to understand storyline clearly. I think English tasks for Russian users will be more fair.