Rating changes for the last round are temporarily rolled back. They will be returned soon. ×

By pikmike, history, 9 months ago, translation, ,

Hello Codeforces!

Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

This round will be rated for the participants with rating lower than 2100. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 7 problems and 2 hours to solve them.

The problems were invented and prepared by Roman Roms Glazov, Adilbek adedalic Dalabaev, Vladimir Vovuh Petrov, Ivan BledDest Androsov, Maksim Ne0n25 Mescheryakov and me. Also huge thanks to Mike MikeMirzayanov Mirzayanov for great systems Polygon and Codeforces.

Good luck to all participants!

Congratulations to the winners:

Rank Competitor Problems Solved Penalty
2 kefaa2 7 346
3 wxhtxdy 6 120
4 square1001 6 136
5 HIR180 6 153

Congratulations to the best hackers:

Rank Competitor Hack Count
1 2014CAIS01 76:-1
2 prateek2112 50:-1
3 takumi152 32:-2
4 Holland_Pig 28
5 sysjuruo 37:-24
1268 successful hacks and 1683 unsuccessful hacks were made in total!

And finally people who were the first to solve each problem:

Problem Competitor Penalty
A Geothermal 0:01
B arknave 0:02
C HIR180 0:06
D RUSH_D_CAT 0:22
E Noam527 0:06
F zhoutb 0:28
G Luma 0:46

UPD: Editorial is out

• +308

 » 9 months ago, # | ← Rev. 3 →   +16 The problems gonna be high-level because it's @PikeMike
•  » » 9 months ago, # ^ |   +18 The problems gonna be delayed...
 » 9 months ago, # |   +36 This group of people have held many educational rounds.Thanks a lot!And I hope that the problems will be as nice as the past educational rounds'.
•  » » 9 months ago, # ^ |   +12 Orz Holland_Pig.
•  » » » 9 months ago, # ^ |   0 Orz Holland_Pig and ZCLG
 » 9 months ago, # | ← Rev. 3 →   +82 [DELETED]
 » 9 months ago, # |   +6 I'm looking forward to this round, cause I hope to turn blue:) Good luck to you all!
•  » » 9 months ago, # ^ |   +1 you are already approximately blue...xD
•  » » » 9 months ago, # ^ |   0 I was closest to blue.
•  » » » » 9 months ago, # ^ |   -10 aree bhai bhai bhai !!!
•  » » » » 9 months ago, # ^ |   +2 You are No.1 of Green:)
•  » » » » » 9 months ago, # ^ |   0 Oh Yes. I didn't see this way:)
•  » » 9 months ago, # ^ |   +32 I did it!
•  » » » 9 months ago, # ^ |   0 Congratulations! :)
•  » » » 9 months ago, # ^ |   0 Congrats!
•  » » » 9 months ago, # ^ |   0 Congratulations :-)
•  » » » 9 months ago, # ^ |   +3 Congratulations!♪(^∇^*)
 » 9 months ago, # |   -39 Just please prove your solutions :))))
 » 9 months ago, # |   +24 I'm hoping to learn something new again in this contest. Because of the last educational round, I learnt the sparse table and binary lifting. Thank you, problem setters for nice educational rounds.
 » 9 months ago, # |   -17 Is there any proof why my contribution is negative ? (without your upvote / downvote to this comment)
•  » » 9 months ago, # ^ |   +12 If a comment has rating between 0 and -5, it's shown that its rating is 0. Your previous comments had rating 0, but maybe they were like -1 or -2 so, after some time, your contribution became -1. I guess that's the reason.
•  » » » 9 months ago, # ^ |   -22 I think this is may be curse of last contest.. SpoilerAhhaa just kidding. May be you are right but this is unfair "_(^-^)_/"
 » 9 months ago, # |   0 Do successful hacks add upto your total score?
•  » » 9 months ago, # ^ |   +13 No,in educational rounds,you can only hack after the round ends for 12 hours.This will not effect your score.But if you hack others' solution successfully,and their ranks are higher than yours,your rank may become higher.
•  » » » 9 months ago, # ^ |   +6 But the possibility of that is quite low .. the hack must include a case the testers didnt notice .. I think it's for educational purpose only
 » 9 months ago, # | ← Rev. 2 →   -34 12hrs System test will be like
•  » » 9 months ago, # ^ |   +42 But the round hasn't even started yet!
 » 9 months ago, # |   0 hope to have a contest !!
•  » » 9 months ago, # ^ |   +10 hope to have a rated contest.
•  » » » 9 months ago, # ^ |   0 I hope, too. Moreover, it is important that this contest become rated even to prevent the contest from being unrated twice in a row.
 » 9 months ago, # |   +9 All the misery was necessary
 » 9 months ago, # |   +39 Educational Rounds and PikMike. Still a better love story than Twilight. 
 » 9 months ago, # | ← Rev. 3 →   +16 I hope everyone gets what he deserves.Good luck everyone!
 » 9 months ago, # |   +29 When it clashes with India's batting.
•  » » 9 months ago, # ^ |   +4 Epicenter major grand final PepeHands
 » 9 months ago, # |   0 if( Educational Round == PikMike || Div 3 == Vovuh ){ print("Contest gonna be lit."); }
•  » » 9 months ago, # ^ |   +9 Are you a C++ coder or a python coder or some language else's?
•  » » » 9 months ago, # ^ |   0 Java coder ;)
• »
»
»
9 months ago, # ^ |
0

# define print printf

:P

•  » » » 9 months ago, # ^ |   0 He's a groovy coder
•  » » 9 months ago, # ^ |   +3 *late
 » 9 months ago, # | ← Rev. 2 →   +7 Sure about timings ? :p
•  » » 9 months ago, # ^ |   +8 And it gets delayed by 10 min '__'
 » 9 months ago, # |   -9 Hope this one's rated :)
•  » » 9 months ago, # ^ |   0 Rated for Div2, that's what it says above. :)
•  » » » 9 months ago, # ^ |   0 I think you didn't understood what he meant :)
•  » » » » 9 months ago, # ^ |   -6 Oh yeah, got it now. xD
 » 9 months ago, # | ← Rev. 3 →   +6 The contest start has been delayed for 10 minutes. I think these days so many contests are delayed.
 » 9 months ago, # |   -6 Why did the time suddenly extend?
•  » » 9 months ago, # ^ |   +29 It seems like new tradition of CF. I am observing it since last 4 contests.
•  » » » 9 months ago, # ^ |   0 LOL !!xD
•  » » 9 months ago, # ^ |   +11 traditions bro. Traditions.
 » 9 months ago, # |   +71 What's with all the delays nowadays?Not to say that I don't appreciate this site, but why not just schedule it 10 minutes later beforehand so we can work on other stuff? Is something unexpected coming up?
•  » » 9 months ago, # ^ |   +36 Exactly I am yet to take my dinner today. And I delayed it for two hours for contest. If i knew it was 10 mins later then I could have managed taking my dinner as well before contest :(.
•  » » 9 months ago, # ^ |   +5 They are waiting for 10k registrations.
•  » » 9 months ago, # ^ |   +10 This 10 minutes is the most boring time of day :3
 » 9 months ago, # |   -7 again timming has be changed!!! :((
 » 9 months ago, # |   +12 again a delay ? ! great !
 » 9 months ago, # |   +15 Finally codeforces scheduled delay takes its place
 » 9 months ago, # |   -6 expecting nice problems!!
 » 9 months ago, # |   +3 Every contest delayed for 10-15 minute . So , why contest time fixed 10-15 minute earlier rather than starting time ?
•  » » 9 months ago, # ^ |   0 They don't do that intentionally, I think.
•  » » 9 months ago, # ^ |   -16 they want to wait until the number of participants increases over 10k
•  » » » 9 months ago, # ^ |   +12 not going to happen even if they delay it by one hour
 » 9 months ago, # |   +3 Delay by 10 minutes and CF rounds! better love story than Twilight :P
 » 9 months ago, # |   +2 I wanted to say thanks for not having a delay, after contest :\
 » 9 months ago, # |   +51 Delayforces
 » 9 months ago, # |   +1 I hope this round is perfect.:)
 » 9 months ago, # |   0 Fantastic!Looking forward to it
 » 9 months ago, # |   +71 arisjo hacked pikmike's account and made this contest
•  » » 9 months ago, # ^ |   0 Good explanation!
•  » » 9 months ago, # ^ |   +1 First of all it's arsijo,, and this kind of aggression towards him !!!! , even aggressive cows didn't have this much aggression towards each other
 » 9 months ago, # |   +3 The contest "codeforced" again.
 » 9 months ago, # |   +6 Test case 3
 » 9 months ago, # | ← Rev. 3 →   +1 If anyone needs help in E question.You can refer to F. Tree with Maximum Cost question. They both are quite similar :)
 » 9 months ago, # | ← Rev. 2 →   +4 In my opinion, C harder than D and E.
•  » » 9 months ago, # ^ |   +2 D was definitely harder, it was hacked left and right.
•  » » 9 months ago, # ^ |   0 I agree. In my opinion hard ad-hoc problems are always harder than problems that need a general algorithm or paradigm to be solved.
 » 9 months ago, # |   +3 What is the 6th testcase for problem C?
•  » » 9 months ago, # ^ |   0 Probably something like 5 2 1 4 5 0 2 5
•  » » » 9 months ago, # ^ |   0 I get correct answer for this case but still got wrong on testcase 6
•  » » 9 months ago, # ^ |   0 try this 10 3 1 3 6 1 6 7 0 2 8
•  » » » 9 months ago, # ^ |   0 I'm getting the correct answer on this still my solution is failing on test case 6 . Submission no 56381811.
 » 9 months ago, # |   -27 A and B super easy. C, D, E, F need some "trick". I do not see the educational point.
•  » » 9 months ago, # ^ | ← Rev. 3 →   +17 C, D and E needed some trick? I didn't use a single data structure, well known algorithm or "trick" in them and in fact I think that C and D were quite interesting.Edit: fuck my life.
•  » » » 9 months ago, # ^ |   0 I got an AC with an horrible brute force, I expect this to be hacked. Worked about two hours on it and I have no real idea of how the solution should look like. Thats what I call "you need a trick".
•  » » 9 months ago, # ^ |   0 E did not need a "trick" in my opinion, it was an interesting DP on Trees problem.
•  » » » 9 months ago, # ^ |   0 Maybe E was to hard for me. But, it is obvious that one need to find the "correct" first node. If you see how to find it, you found the trick.
•  » » » » 9 months ago, # ^ |   0 no you can find the answer for all vertices on o(n)
 » 9 months ago, # |   0 What is the approach of Problem E?
•  » » 9 months ago, # ^ |   +6 Similar to 1092F - Tree with Maximum Cost. DP on Trees
•  » » 9 months ago, # ^ |   +1 How to solve D?
 » 9 months ago, # |   -21 what the fuck was test case 6 of que 3
 » 9 months ago, # |   0 E is very similar to 1092F - Tree with Maximum Cost. (I know being original is not a priority, I'm just saying in case it benefits some people).
•  » » 9 months ago, # ^ |   +10 I solved that F problem without any help,but couldn't solve E now...
•  » » 9 months ago, # ^ |   0 I did E using sliding through nodes only(Sliding Window??)
•  » » » 9 months ago, # ^ |   0 I read your solution could you explain in bit detail please.How are you managing window on tree, heard it first time,seems interesting!!
•  » » » » 9 months ago, # ^ |   0 Not actually windowing but if I find answer for any node say, 1 then for its children it will be just addition of a quantity a-b
•  » » » » » 9 months ago, # ^ |   +1 So you are using the concept of re-rooting basically and finding the effect of traversing one node below the given node.
•  » » » » » » 9 months ago, # ^ |   0 Yes
•  » » 9 months ago, # ^ |   0 Oh,I solved it,They are REALLY similar problem... interesting,of course...
 » 9 months ago, # |   +23 What is "Unexpected verdict" for hacks?
•  » » 9 months ago, # ^ |   +35 Maybe hack so strong even author's solution crashed
•  » » » 9 months ago, # ^ |   +43 Not author's, just tester's.
•  » » » » 9 months ago, # ^ |   +15 lmao
 » 9 months ago, # |   +3 How to solve D?
•  » » 9 months ago, # ^ |   0 int n; cin >> n; int a[n]; int b[n]; vsi dp; si tmp; dp.assign(n, tmp); for (int i = 0; i < n; i++) { cin >> a[i]; a[i]--; dp[a[i]].insert(i); } for (int i = 0; i < n; i++) { cin >> b[i]; b[i]--; } SegTree st(a); bool fl = true; for (int i = 0; i < n && fl; i++) { if (dp[b[i]].size() != 0) { int ind = *(dp[b[i]].begin()); dp[b[i]].erase(dp[b[i]].begin()); if(ind == 0){ a[ind]=(1<<30);// is not necessary st.update(ind , (1<<30)); continue; } int min = st.rmq(0 , ind-1); if(a[min] < a[ind]) fl = false; else{ //update segment tree and with INF value instead of delete a[ind]=(1<<30); // is not necessary st.update(ind , (1<<30)); } } else fl = false; } if(fl) cout << "YES\n"; else cout << "NO\n";
 » 9 months ago, # |   +7 Hacks for C and D?
 » 9 months ago, # |   0 Testcase #6 for C. My approach : all segment of type 1 is increasing order. initial value = 1e7.(value greater than 1000) fill rest in decreasing order staring from 1000. Check if it violates type 0 segment rule. what is the problem?
•  » » 9 months ago, # ^ | ← Rev. 2 →   0 You will get wrong for testcase: 5 2 1 2 5 0 1 5
•  » » 9 months ago, # ^ | ← Rev. 3 →   0 Have you tried this case: 7 4 1 1 3 1 5 7 0 3 4 0 4 5 
 » 9 months ago, # |   0 idk how but this code gives me correct output on terminal for test case 1, but I get wrong answer on test case 1 on codeforces, https://codeforces.com/contest/1187/submission/56341353. Can someone please tell me why this is happening, it happened to me so many times before.
•  » » 9 months ago, # ^ |   +2 You forgot to return true in your chk() function.
 » 9 months ago, # |   +23 Hackforces?
 » 9 months ago, # |   0 Problem E, in first test sapmle, why answer is 36? I think i even didn't understand the problem(
•  » » 9 months ago, # ^ |   +7 Start from node 7 or 8.
 » 9 months ago, # |   0 How to solve C?? what I did was 1st checked whether if there exists an unsorted array b/w some sorted one then answer would be no otherwise yes. To print the array I replaced the non-sorted last index with the min(value int the given range) -1 .. got WAcan anyone provide me the test case(smaller one) where it will be wrong and the correct approach to do it.
 » 9 months ago, # | ← Rev. 3 →   0 C -> whats wrong with my approach ? My approach : sort all pairs of type 1; take a initial value greater than 1000. for first segment of type 1 fill the segment with increasing value starting from initial value. for each segment except first. if starting point<=ending point of previous segment then do not reset previous value. continue increasing from there.else if starting point>previous ending point reset to initial value.fill rest in decreasing order staring from 1000. Check if it violates type 0 segment rule. what is the problem?
•  » » 9 months ago, # ^ |   +1 Overlapping ranges... I think you need to check every single index, if index and index+1 must be sorted, or must be unsorted. Then you can build the array easyly.
•  » » » 9 months ago, # ^ |   0 that is great thinking but I thought I handled overlapping segments. For type 1 segments I merged the segments . and for type 0 I checked is they are ok after building the array: 56343410 Can You give me a small hack..please?
•  » » » » 9 months ago, # ^ | ← Rev. 2 →   0 You might have ranges like 1 1 10 1 2 4 1 6 12 If you sort for 1, 2, 6, you will loose the 10 while checking if 6 is gt 4. So you decrease the counter on segment (6, 12), which violates rule for segment (1, 10).... But I am not really sure about that... just a guess ;)
•  » » » » » 9 months ago, # ^ |   0 No..you are correct. that is the case
 » 9 months ago, # |   +2 Today Problem A was a night mare to me . Got AC on 6th attempt.
 » 9 months ago, # | ← Rev. 2 →   0 There was DP on tree in E, isn't it?P.S. Great contest!!!! Wish every contest gonna be like that.UPD: C dropped
•  » » 9 months ago, # ^ |   0 Yes, it was DP on tree
 » 9 months ago, # |   +39 Lol what are all the hacks in D?
 » 9 months ago, # | ← Rev. 2 →   +34 Hack case for D:155 4 1 2 31 2 3 5 4 answer must be YES
•  » » 9 months ago, # ^ |   0 Wow, didn't think of that :(
•  » » 9 months ago, # ^ |   +12 I got this right but still got hacked, any other case?
•  » » » 9 months ago, # ^ | ← Rev. 2 →   +9 1131 7 1 4 4 5 6 13 10 4 4 5 61 1 4 4 5 7 6 10 4 4 5 6 13answer must be YES
•  » » » 9 months ago, # ^ | ← Rev. 4 →   0 Another hack case 1 8 2 3 4 5 6 5 1 4 1 2 3 4 5 6 5 4
 » 9 months ago, # |   +12 HACKFORCES at its best.
 » 9 months ago, # |   0 C. Maybe someone could help me? I don't understand, why my solution didn't work. What criterium to say "NO"? (In my sol I sort all conditions on left bound, connect them(conditions {1 2 5}, {1 3 6} will be {1 2 6}) and build for O(n) answer). Solution.
•  » » 9 months ago, # ^ |   +3 After you build the array using the "1" facts, loop through all of the "0" facts to see if any of them are sorted.
 » 9 months ago, # |   +3 Can anyone tell how to solve B? Tried for like whole contest but Everytime time limit exceeded on test case 4.
•  » » 9 months ago, # ^ |   +6 Build a pref matrix: matrix[letters][index], then use it to find the least indice that for each letter in the name, matrix[letter][index] >= frequency[letter] in the given string.
•  » » 9 months ago, # ^ | ← Rev. 2 →   +4 First pre-compute the given string by taking a vector of vector of size 26 and insert there indexes . Then for each query make a frequency array for all 26 letters and iterate frequency array and if frequency is not 0 check for the minimum index needed for given frequency in pre-computed array . Here is my solution
•  » » » 9 months ago, # ^ |   0 Ohhk i got it.
•  » » » 9 months ago, # ^ | ← Rev. 2 →   0 ty
•  » » » 9 months ago, # ^ |   0 Why do the tags have Binary Search though?
•  » » 9 months ago, # ^ |   +6 Your solution is probably $O(N\sum{t_i})$. You need to pre-process the string in order to quickly answer the farthest position needed for each name. You can do this by storing the $k$th occurrence of each letter. Then you just have to use this lookup table to find the answer for each name. Then the runtime is $O(N+\sum{t_i})$ (plus a constant factor for the size of the alphabet).
 » 9 months ago, # | ← Rev. 2 →   0 I am generating a large Test case for hacking for Problem D. I am generating Test cases in which n is of the order of ${300000}$ and ${t = 1}$. But when I try to hack someone it says Test Cases cannot be longer than 256KB. Why it is happening, In question it is mentioned that ${n}$ can go upto ${300000}$. Can anyone Tell me the reason.
•  » » 9 months ago, # ^ |   +1 You should generate big tests with "generated input", in case you were just copying your test cases. I may be wrong
•  » » 9 months ago, # ^ |   +6 For testcases larger than 256KB you need to upload a generator i.e. a program which prints that testcase.
•  » » 9 months ago, # ^ |   0 use generator for large test case
 » 9 months ago, # | ← Rev. 2 →   +5 How to solve D? Some people suggested the answer was to count inversions of each individual number and check those, but then they got hacked.
•  » » 9 months ago, # ^ | ← Rev. 2 →   +9 The key idea is the following: you need to sort subsegments of length 2, i.e. swap pair of consecutive elements if the first one is larger.Let's suggest that the element $b[1]$ is in the position $a[pos]$. If $min(a[1..pos]) < a[pos]$ then there is no way to move $a[pos]$ to $a[1]$. Otherwise, we can move it and, moreover, relative order of $a[1..(pos - 1)]$ doesn't change. So we "delete" $a[pos]$ and $b[1]$ and solve recursively.Of course, you need to write it in an efficient way.
•  » » » 9 months ago, # ^ |   0 but how can i get index "pos"?? will u pls share yur solution !!
•  » » » » 9 months ago, # ^ |   0 Considering that solution as correct, you can make an array of vector of size 3*(1e5)+1 and store the indices of the input elements inside the vector. That way you can always obtain pos in O(1) time
•  » » » 9 months ago, # ^ |   0 Consider this : 1 5 3 1 2 4 1 1 2 1 3 4 According to your solution, first element 3 can move to a maximum of 3rd index (consider 1-based indexing). But it can go till 4th index if we swap indexes 4 and 5. Also in that case relative order changes. Answer to this test shall be "YES". If I didn't get your code correctly please elaborate
•  » » » » 9 months ago, # ^ |   0 You should move not $a[1] = 3$ to the right, but $a[2] = b[1] = 1$ to the left. Then you get array $a = [1, 3, 2, 4, 1]$ and $b = [1, 2, 1, 3, 4]$. Next step is to move $a[3] = b[2] = 2$ to the position $2$, $a[5] = b[3] = 1$ to the position $3$ and that's all.
•  » » 9 months ago, # ^ |   0 Match indices of a to corresponding indices of b (this matching is unique if equal elements aren't reordered). Create an array pos where pos[i] = j means that a[i] is matched to b[j]. Then, if there is some pair (i, j) such that i < j, a[i] < a[j] and pos[i] > pos[j], then the answer is NO. So this gives a necessary condition that no such pairs exist. I didn't prove it's sufficient though :(
•  » » 9 months ago, # ^ |   0 Keffa2's solution this might help...
•  » » 9 months ago, # ^ |   +15 First check that arrays are permutations, and get the map fuction $p$ such that if the $k$-th occurrence of value $v$ in $A$ is in position $i$, and the $k$-th occurrence of value $v$ in $B$ is in position $j$, then $p(i) = j$.Then, instead of "sorting a range", think of your operation as "swapping consecutive elements $A_i$ and $A_{i+1}$ if $A_i > A_{i+1}$", if you can get to an array by sorting ranges, you can also get to it by swapping consecutive elements, like that.You can notice that your operation allows you to "remove" already existing inversions, but you definitely can't create new ones. Then, finding a single "new" inversion present in $B$ is enough to answer NO, and, I haven't proved this yet, but I think that if you don't have any "new" inversion, then you can safely answer YES.You can check that you are not creating new inversions by going through the array $A$, and maintaining a segment tree that answers the maximum in a range. The idea is that $ST[v]$ is the maximum index (in $B$) in which an already seen value of $v$ (in $A$) ends up. When you are at position $i$, check if there was a previous smaller value $v$ ($v \leq A_i$) that ends up after $A_i$, if this happens, you can already say NO. Otherwise, just update the $ST$ accordingly.The code snippet might be easier to understand: for(int i = 0; i < n; ++i){ int mx = ST.query(0, A[i]); if(mx > p[i]){ ok = false; break; } ST.upd(A[i], p[i]); } You can also check my code: 56332559.
•  » » » 9 months ago, # ^ |   +5 Your claim about inversions can be proven by induction on $n$, the length of the given arrays. In the step you just have to notice that first $n-1$ values of the first array, on which we swap adjacent elements, can be sorted in the same way they are sorted in the second array, if we neglect $a_n$ (the arrays are indexed from 1). That is true by the hypothesis. And now it just remains to somehow deal with the $a_n$. But it is not hard to prove that it can go to its appropriate position. All you need to do is to notice that if there was an inversion that consists of $a_n$ in the first array before the change of the order of its first $n-1$ elements, then the same inversion exists after that change and vice versa.
•  » » 9 months ago, # ^ |   0 int n; cin >> n; int a[n]; int b[n]; vsi dp; si tmp; dp.assign(n, tmp); for (int i = 0; i < n; i++) { cin >> a[i]; a[i]--; dp[a[i]].insert(i); } for (int i = 0; i < n; i++) { cin >> b[i]; b[i]--; } SegTree st(a); bool fl = true; for (int i = 0; i < n && fl; i++) { if (dp[b[i]].size() != 0) { int ind = *(dp[b[i]].begin()); dp[b[i]].erase(dp[b[i]].begin()); if(ind == 0){ a[ind]=(1<<30);// is not necessary st.update(ind , (1<<30)); continue; } int min = st.rmq(0 , ind-1); if(a[min] < a[ind]) fl = false; else{ //update segment tree and with INF value instead of delete a[ind]=(1<<30); // is not necessary st.update(ind , (1<<30)); } } else fl = false; } if(fl) cout << "YES\n"; else cout << "NO\n";
 » 9 months ago, # |   0 These submissions are very similar
•  » » 9 months ago, # ^ |   +12 That's what happen when someone shares his solution with one friend, and don't share it with the other lol
 » 9 months ago, # |   +1 please anyone explain B ?
•  » » 9 months ago, # ^ |   +1
•  » » 9 months ago, # ^ |   +1 just store Kth occurance of every character like count[ch][k]=i (character ch appeared k times at index i) then count the occurance of every character from query string. for example in query string 'a' appeared 2 times 'b' appeared 3 times. so the answer will be maximum of count['a'][2] and count['b'][3]
 » 9 months ago, # |   +126 So this is what happened today: I solved A, B, C, D, E and was finally about to be master *_* Plot twist 1: 5 mins after the contest, my D got hacked. No master for me :( Plot twist 2: A lot of people had their D hacked. I was going to be a master after all *_* Plot twist 3: My C got hacked. Oops, not going to be a master :( Requesting all hackers to add another plot twist here (By hacking other people's solutions, not mine :P)
•  » » 9 months ago, # ^ | ← Rev. 2 →   +26 at the end, the editorial get hacked and the contest becomes unrated...happy ending for every hacked person :-)
•  » » 9 months ago, # ^ |   0 How was the answer for E =36? for 1st testcase?
 » 9 months ago, # |   +10 The people who end hacking D starts hacking C. XD
•  » » 9 months ago, # ^ |   0 What should be the condition for printing NO in problem C?
•  » » » 9 months ago, # ^ |   0 An unsorted fact is fully contained in a range that has to be sorted which is the union of overlapping sorted facts. You make the all the sorted ranges were non-decreasing and everything in between decreasing and check if it satisfies the unsorted facts.
•  » » » » 9 months ago, # ^ |   0 Thanks , earlier I was considering that even a partial overlapping will lead to answering NO, Also I have another question. The Problem statement mentions that some range will be sorted and some won't, but if the ranges does not cover the entire array , what can be said about the range which is not covered in the queries. Should that be sorted or unsorted. eg:- if array size is 6 and the ranges are (1-indexed) 3-4 4-6 what about 1-2 ?
•  » » » » » 9 months ago, # ^ |   0 Make them anything you want, it doesn't matter. You could just make anything outside of a sorted range unsorted so that you satisfy as many unsorted facts as possible, and then check if all the unsatisfied facts are true. If one of the facts aren't true, there's no solution since you're already making as much of the array unsorted as possible.
 » 9 months ago, # | ← Rev. 2 →   0 simple test hack for D -_-:1 3 3 2 1 1 3 2
 » 9 months ago, # | ← Rev. 2 →   +3 Before start hacking, the number of a test case of Problem D was 18, and there are 74 now. :O
•  » » 9 months ago, # ^ |   0 Pretty much means some solutions might be filtered out during the system test so don't be too happy if your solution hasn't been hacked (notes to myself... ahem).
•  » » 9 months ago, # ^ |   +3 Lol, there are 152 test cases right now :)
•  » » » 9 months ago, # ^ |   0 How do you check that?
•  » » » » 9 months ago, # ^ |   +11 You can resubmit your solution and it will be tested on the full set of test cases
 » 9 months ago, # | ← Rev. 2 →   +1 Many people have been hacked on D, including me.. We should use data structure to solve.
 » 9 months ago, # |   +13 Any hint for F?
•  » » 9 months ago, # ^ | ← Rev. 2 →   +26 Answer is $E[(1+\sum_{i = 1}^{i = n-1}(x_{i} != x_{i+1}))^2]$ = $E[(1 + \sum_{i=1}^{i=n-1}(x_{i} != x_{i+1})^{2} + 2\times \sum_{i=1}^{i=n-1}(x_{i} != x_{i+1}) + 2 \times \sum_{i!=j}(x_{i} != x_{i+1})(x_{j} != x_{j+1})]$. Now use linearity of expectations to calculate it.
 » 9 months ago, # |   +124
 » 9 months ago, # |   +37 Can anyone explain the idea of Problem F ?Thanks in advance.
•  » » 9 months ago, # ^ |   +1 Count expected number of group pairs.
 » 9 months ago, # |   +6 C and D — R.I.P. It's gonna be very nice system testing))0)
 » 9 months ago, # |   +78 Do upvotes increase contribution points? If yes, can I get some upvotes just to get some contribution points? I currently have none :(
•  » » 9 months ago, # ^ |   +28 Yes and Yes :)
 » 9 months ago, # |   0 After system testing no one has solved problem D ^^
 » 9 months ago, # | ← Rev. 3 →   0 what is the hack in C? so many purples have been hacked
 » 9 months ago, # |   0 Wow, more than 600 solutions on problem D passed on pretests and now it's only slightly more than a 100. What's so wrong with this problem, did everyone try to do something greedy? My solution is stupid, what could possibly go wrong.
•  » » 9 months ago, # ^ |   0 even C is turning out like that
•  » » » 9 months ago, # ^ |   0 C is a constructive task, so no doubts with a small amount of tests you can't really filter the small mistakes. But in D they even had multitests! It blows my mind.
•  » » 9 months ago, # ^ |   +3 there was not strong tests for D , unlike E.
 » 9 months ago, # |   +19 I was rank bout 200 at the end of contest.But now,I am rank74. That's hackforces.
•  » » 9 months ago, # ^ |   +16 Happiness comes to you quickly like a storm LOL :D
 » 9 months ago, # |   +5 This round's D will like this problem,which has 588 tests
 » 9 months ago, # |   0 7 7 2 3 6 5 4 1 1 2 3 6 4 5 7problem D, i excute some ac codes, result is YES, and unsuccessful hackanyone can help explain? i think it is NO.
•  » » 9 months ago, # ^ | ← Rev. 2 →   0 Apply the operation to [5, 6] to swap them, [1, 2], [2, 3], [3, 4]... to move 7 to the end, and [5, 6], [4, 5], [3, 4]... to move 1 to the beginning. (numbers in brackets are indices, 1 indexed)
•  » » 9 months ago, # ^ |   0 7 7 2 3 6 5 4 1 1 2 3 6 4 5 7first sort [5,4,1] then it'll be 7 2 3 6 1 4 5 then [7,2,3,6,1] it'll be 1 2 3 6 7 4 5 then [7,4,5] it'll be 1 2 3 6 4 5 7 which is equal to B
 » 9 months ago, # |   +3 Weak test cases for C and D
 » 9 months ago, # |   0 How to solve B? I think I have overcomplicated using the precomputation and binary search.
•  » » 9 months ago, # ^ | ← Rev. 2 →   0 Binary search is not needed. Look at my code.(https://codeforces.com/contest/1187/submission/56315851)
•  » » » 9 months ago, # ^ |   0 Thank you
 » 9 months ago, # |   +3 Okay, so I think you gave such weak tests on purpose.
 » 9 months ago, # |   0 Another 2 solve contest lol im gonnna drink some beer
 » 9 months ago, # | ← Rev. 2 →   +57 When you go from -65 to -13
 » 9 months ago, # |   0 What is the idea behind C?
•  » » 9 months ago, # ^ |   0 Greedy. Lets make unsorted all the subarrays that don't required to be sorted. Note that if we have to intervals $[i_1,i_2]$ and $[j_1,j_2]$ that needs to be sorted, and if $i_2 >= j_1$ then the interval $[i_1,j_2]$ needs to be sorted as well. So lets find all actual intervals that needs to be sorted using the rule above. Suppose that those intervals are $[l_1, r_1],[l_2, r_2],...,[l_k, r_k]$. We can fill in them starting from the first one by assigning the $n$ to all the positions within the $[l_1, r_1]$, $n-1$ within the $[l_2, r_2]$ and so on. Finally check wherther all condition with $t==0$ holds. If not, there is no answer, otherwise you have already found one. It may seem that we need to fill in the segmends between sorted intervals somehow but actually they can be handled as a sorted intervals with length 1.
•  » » » 9 months ago, # ^ |   0 Thank You But How we fill other that sorted intervals?
•  » » » » 9 months ago, # ^ |   0 Imagine that we need to produce an unsorted array of length 4. Its clear that intervals $[1;1],[2;2],[3;3],[4;4]$ needs to be sorted (yep, array of length 1 is allways sorted, but the goal is to see how the algorithm above will handle them). If we run an algo on this intervals we will get the following array: $[4,3,2,1]$. As you can see, all the subarrays of this array with $length > 1$ are unsorted.
•  » » » » » 9 months ago, # ^ |   0 Hi Can you provide Me the code?
•  » » » » » » 9 months ago, # ^ |   0 56403000 Sorry for the delay in my response, I was at work.
•  » » » » » » » 9 months ago, # ^ | ← Rev. 2 →   0 Thank you bro. But i think you code is very complex. I saw some of the red codes and they were just like 20-30 Lines But i couldnt get them :(
•  » » 9 months ago, # ^ |   0 I use the Disjoint set to make the interval of sorted, then i test the unsorted case in it.
 » 9 months ago, # |   +21 problems are good,but pretests are too weak
 » 9 months ago, # |   +25 Hey PikMike, Editorials please !!
»
9 months ago, # |
-51

whats wrong in my code????? please someone tell me...

# include <bits/stdc++.h>

using namespace std;

int main() { int t; cin>>t; string str; getline(cin,str); int n; cin>>n; string p; getline(cin,p); vector a(t); for(int j=0;j<n;j++) {for(int k=0;k<t;k++) { if(p[j] == str[k]) {a.push_back(k); } }} double max = *max_element(a.begin(), a.end()); cout<<"Max value: "<<max<<endl;

return 0;

}

 » 9 months ago, # |   +22 Is there any simple solution for D which does not use segment tree?
 » 9 months ago, # |   0 Could someone check out my submission and tell me what do the diagnostics mean. I am not able to interpret it. Submission no — 56381811 Thanks in advance.
•  » » 9 months ago, # ^ |   +1 The actual error is:Error: attempt to subscript container with out-of-bounds index 161, but container only holds 161 elementsThis is saying that you are trying to access element number 161 in a container (a vector, I think) that contains only 161 elements. This is an error because, in such a vector, the elements are numbered from 0 to 160.Looking at your code this might be in merge(), where you index with j+1:  for(;j
 » 9 months ago, # |   0 for(int i=0;i
•  » » 9 months ago, # ^ |   0 " \n"[i==n-1] is a way to print a space when i
 » 9 months ago, # |   +14 So where is the Editorials?
•  » » 9 months ago, # ^ |   -11 NYP
•  » » » 9 months ago, # ^ |   0 What does NYP mean?, Not your problem?
•  » » » » 9 months ago, # ^ |   0 Not yet published
 » 9 months ago, # |   +6 Was not able to solve any question but will try next time Wish me luck
 » 9 months ago, # |   0 Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).
 » 9 months ago, # |   0 In problem C, for sorted subarrays, most of the solutions are doing +1 for L[i] to R[i] — 1. Why not L[i] to R[i]? Why is R[i] not being taken into consideration?
 » 9 months ago, # |   0 Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).
 » 9 months ago, # |   0 It would be so helpful if we could get a brief tutorial/solution guide.. :)