Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

By pikmike, history, 4 weeks 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 6 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 the participants!

Our friends at Harbour.Space also have a message for you:

Hi Codeforces!

As a special prize for the Educational Round 81, we would like to invite the top participants to take part in our Hello Muscat ICPC Programming Bootcamp, which will take place in Oman, from March 19 to March 25, 2020. The prize will cover the participation fee, accommodation, and half-board meals for the entire duration of the bootcamp (except flights)!

There are three requirements to satisfy:

• You took part in at least 10 rated contests on Codeforces
• Your max rating should be less than 2400
• You should be eligible for ICPC and/or IOI 2020+
Fill out the form→

Good luck to everyone!

We are also excited to announce that we are working with our partners to provide free participation (flights not included) for the teams going to the ICPC World Finals 2020, which will take place in Moscow. If you and your team qualified for the Finals, fill out the form below to see if you’re eligible.

Apply Now→

Congratulations to the winners:

Rank Competitor Problems Solved Penalty
1 nickluo 6 177
2 KrK 6 184
3 NoLongerRed 6 185
5 neal 6 204

Congratulations to the best hackers:

Rank Competitor Hack Count
2 rachit_raj 51:-1
3 harshraj22 41:-5
1096 successful hacks and 873 unsuccessful hacks were made in total!

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

Problem Competitor Penalty
A antontrygubO_o 0:01
B neal 0:05
C IgorI 0:07
D NoLongerRed 0:06
E A_Fan_of_the_AK_King--lk 0:14
F Combi 0:23

UPD: Editorial is out

• +67

 » 4 weeks ago, # |   0 Educational Rounds always have good problems. Hope for a good contest.
 » 4 weeks ago, # | ← Rev. 2 →   +117 Finally a contest ! Hope the gap between rounds will decrease
 » 4 weeks ago, # |   +45
 » 4 weeks ago, # |   +72
•  » » 4 weeks ago, # ^ |   +23 It feels more longer to users whom Div.3 contest is unrated for.
 » 4 weeks ago, # |   +26
•  » » 4 weeks ago, # ^ |   -10 Wish not.
•  » » 4 weeks ago, # ^ |   0 I see this happening to me.
 » 4 weeks ago, # |   +27 Petition to MikeMirzayanov to decrease the gap between forthcoming contests.
 » 4 weeks ago, # |   -9 Looking forward to interesting problems
 » 4 weeks ago, # |   +43 Vovuh are you the Vladimir Petrov who won IMO Gold in 2018?
•  » » 4 weeks ago, # ^ |   +62 Unfortunately, no :(
 » 4 weeks ago, # |   +23 Lets hope that the frequency of contests increases.
 » 4 weeks ago, # |   -21 Problems are difficult!
•  » » 4 weeks ago, # ^ |   0 I don't think so.
 » 4 weeks ago, # | ← Rev. 5 →   -33 B and C are difficult.
•  » » 4 weeks ago, # ^ |   -37 B and C are difficult for Newbies.
 » 4 weeks ago, # |   +87 Even if the problem is not original, I think providing links to such problems and solutions during contest violates the CF round rules. Let us keep silence until the end of the round.
 » 4 weeks ago, # |   +18 Finally solved the first problem. Heading for second. So much to learn...!!
 » 4 weeks ago, # |   +17 I guess, someone accidentally swapped B and D :)
•  » » 4 weeks ago, # ^ |   +1 D is easy if you know some number theory, but B is just casework, I don't think it's harder.
 » 4 weeks ago, # |   +35
•  » » 4 weeks ago, # ^ |   +9 bilal saeed hoooooooooooooooo!!!!!!!!!!!!!!!!!!!
•  » » » 4 weeks ago, # ^ |   +4 aaaaaaaaaaaaaaa!!!!!!!!!!!!!!
 » 4 weeks ago, # |   +27 A Problem of APIO 2016:BoatA harder version of problem F.
 » 4 weeks ago, # |   +19 C was similar to https://atcoder.jp/contests/abc138/tasks/abc138_e
•  » » 4 weeks ago, # ^ | ← Rev. 18 →   0 I consider C as a problem which I've solved it before.Unfortunately,I couldn't remember it exactly while the round.Now I can get it.
•  » » » 4 weeks ago, # ^ |   0 how to solve C ?
 » 4 weeks ago, # |   0 How to solve D?
•  » » 4 weeks ago, # ^ |   +18 Find g=gcd(a,m). Divide m by g, i.e. let f=m/g. Find Euler Totient Function value of f i.e. phi(f).
•  » » » 4 weeks ago, # ^ |   0 Why?
•  » » » » 4 weeks ago, # ^ | ← Rev. 2 →   +22 Okay, we know gcd(a, b) = gcd(b, a%b)So gcd(a+x,m) = gcd(m, (a+x)%m) and value of x lies between [0,m-1] that means possible values of (a+x)%m are [0, m-1] because (a+x)%m keeps on incrementing till it completes the full modulo cycle.
•  » » » 4 weeks ago, # ^ |   0 do u have any proof ?
•  » » » » 4 weeks ago, # ^ |   +8 Let's say gcd(a, m) = gWe know gcd(a, m) = gcd(g*p, g*q) where gcd(p, q)=1 and (0 <= p < q). So we have to choose such x those satisfy gcd(a+x, m) = gcd(g*p, g*q). So we all have to do is find the number of co-prime of q those are less than q. So we have to call phi(q). sorry for my bad english...
•  » » » » » 4 weeks ago, # ^ |   0 Thanks for your explaination. I still don't understand the final step. I am only able to get phi(q+a/g)-phi(a/g) by the above steps instead of phi(q).
•  » » » » » » 4 weeks ago, # ^ |   0 gcd(a+x,m)=gcd(m,(a+x)%m)=gcd(g*q,g*p) note that (a+x)%m will always be less than m and can take up any value from 0 to m-1. So finding phi(q) will suffice.
•  » » » » » » » 4 weeks ago, # ^ |   0 Still didn't get it.Can you please elaborate more?I have the same doubt as tycw.
•  » » » » » » » » 4 weeks ago, # ^ |   0 What we think about should be (a+x)%m instead of a+x. So the range of answer becomes [0,m).
•  » » » » » » » » » 4 weeks ago, # ^ |   0 Okay, but how its ensured that all the numbers we get will be >=a,in phi(m/gcd)?
•  » » » 4 weeks ago, # ^ |   0 why
 » 4 weeks ago, # |   0 How to solve E?
•  » » 4 weeks ago, # ^ |   +27 keep segtree on array where arr[i]=cost if you split at i, start by putting everything on the right and leaving the left empty, so arr[0]=a[0], arr[1]=a[0]+a[1]... then start by putting 1 on the left, then 1 and 2, then 1,2 and 3 and so on. when you put a new number on the left the cost for all splits with that number already on the left decrease by a[position[i]], the cost of all the splits without that number (the ones with i
•  » » » 4 weeks ago, # ^ |   0 Thx a lot!
•  » » 4 weeks ago, # ^ | ← Rev. 8 →   +3 Another segment tree solution that doesn't require range update/lazy propagation:Represent each segment by the triple $(suml, sumr, cost)$. Define the combination of two segments as follows: $A + B = (suml_A + suml_B, sumr_A + sumr_B, \min(cost_A + suml_B, sumr_A + cost_B))$ (this operation is not commutative, but it is associative)Start with $tree[p_i] := (0, a_i, 0)$. Iterate $i$ over $[1, n-1]$ by updating $tree[p_i] := (a_i, 0, 0)$, then grabbing the $cost$ value from the "sum" of the entire segment tree. The answer is the minimum $cost$ value retrieved.Explanation: Fix a split of the permutation to sets $L$ and $R$. $suml$ represents the sum of the costs of $L$ in that segment, likewise $sumr$ for $R$. Now consider how to combine the statistics for segments $A$ and $B$. Combining the sums is obvious, but what is $cost$? Consider there is a point $x$ within the segments where we want to move all points $i > x$ from $L$ and $i < x$ from $R$. If $x$ is in the left segment ($A$), the new cost is $cost_A + suml_B$, as we must move all members of $L$ in the right segment ($B$). If $x$ is in $B$, the new cost is $sumr_A + cost_B$ as we must move all members of $R$ in $A$. We thus pick the minimum of these two scenarios. The updates progressively move elements from $R$ to $L$ as the initial split. Be sure not to move the last element, or your answer would always be spuriously $0$.Sample: 69829539
 » 4 weeks ago, # | ← Rev. 3 →   +23 Am I stupid? How do you solve D? I got to count numbers $b$ with $0 <= b < m$ with $gcd(m, b) = gcd(m, a)$ but made zero progress afterwards Edit: As I look at my previous claim I realize that my proof in-contest is flawed. Does anyone know if the statement is actually correct? Looking at the solution given, my statement should be true but I am unable to prove it.Edit: Just kidding, not flawed. $gcd(a, b) = gcd(b$%$a, a)$ which easily applies to $gcd(m, a+x) = gcd((a+x)$%$m, m)$ since $a+x$ takes on m consecutive unique values, we know it takes on every integer $[0, m)$ exactly once.
•  » » 4 weeks ago, # ^ |   +15 Let $d = gcd(m, a)$ and $m_1 = m / d$, $a_1 = a / d$, $b_1 = b / d$. Then $gcd(m_1, a_1) = gcd(m_1, b_1) = 1$.In other words, you have to count numbers $b_1$ with $0 \le b_1 < m_1$ which are coprime to $m_1$. This is actually an Euler function, $\varphi(m_1)$.
•  » » » 4 weeks ago, # ^ |   +3 Pretty neat approach.
•  » » 4 weeks ago, # ^ |   0 Yes, but there is one more condition on b, that b >= a. It can be easily done by just altering the algorithm for calculating the Euler Totient Function.
•  » » » 4 weeks ago, # ^ |   0 There must be some reduction to get this statement with b. At least unmodified totient function works: 69784007
•  » » 4 weeks ago, # ^ |   +3 We can reduce the problem to couting the number of numbers relatively prime to m on interval [0..m/gcd(a, m)]. Let's say that m = m/gcd(a, m). Firstly you need to factorise m and store vector of unique prime factors. Then you can use the principle of inclusion and exclusion to calculate the number of such numbers that have common prime divisor with m.
•  » » » 4 weeks ago, # ^ |   0 I solved it in a similar way.
•  » » 4 weeks ago, # ^ |   +36 I've done it kinda differently compared to the Euler Totient guys here. Using the statement notations, we have a, m, and x. a = gcd*u and m = gcd*v, where (a, m) = gcd so (u, v) = 1 gcd must divide (a+x) so gcd must divide x therefore we have x = gcd*yWhich brings us to an equivalent problem: find the count of y for which: (u+y) and v are coprime, where y is in range [0, v), aka their gcd is 1.For that, I used the principle of inclusion/exclusion because v had something like 12 factors maximum. And because I was in full blown panic mode and couldn't think of Euler.
•  » » » 4 weeks ago, # ^ |   +1 Can you explain your code how are you computing number of y's so that gcd(u+y,v)=1.??
•  » » » » 4 weeks ago, # ^ |   +9 Do you know about the Inclusion and Exclusion Principle? I'll count the values of y for which the gcd will be different than 1: divisible with p1, p2, ... or pk, where p[1...k] are all prime factors of v. That's done with above mentioned principle: you basically consider all subsets of {p1, p2, ... pl} and you either add or remove their count from the result depending on the parity of its size. https://codeforces.com/contest/1295/submission/69761793 I'm hoping my code is actually correct, as in it doesn't fail after the hacking phase. It's really short once you remove the comments.
•  » » » » » 4 weeks ago, # ^ | ← Rev. 2 →   0 Hey bro can you tell how is u + y == v (mod x), and what computation you are doing in your solve function after taking all the numbers from the set.
•  » » » 4 weeks ago, # ^ |   0 Great minds think alike!
•  » » » 4 weeks ago, # ^ | ← Rev. 2 →   +5 Nice. But if the range of x is: 0 <= x < 2m Then Euler Phi does not work I guess. Like if a=8, m=12 and for 0<=x gcd(a+x,m) = gcd((a+x)%m),m) (according to many comments) which says that no matter what is x's range, we only need to find the Phi(m/gcd(a,m)) which is incorrect for x's various range.
•  » » 4 weeks ago, # ^ |   0 How did you come up with gcd(m,a) = gcd(m, b). Couldn't understand this part.
•  » » » 4 weeks ago, # ^ |   0 gcd(a+x,m) = gcd((a+x) mod m, m), so in fact you just need to check which remainders of m have the same gcd as a.
•  » » » » 4 weeks ago, # ^ |   0 we have to check no of coprime with m in range(1,m-1)?
•  » » » » » 4 weeks ago, # ^ |   0 Not exactly, because you are looking for the numbers in range(1, m-1) which have the same gcd with m as a has (which is not necessarily 1).
•  » » 4 weeks ago, # ^ |   0 How do you make GCD (a, m) = GCD (b, m)
•  » » » 4 weeks ago, # ^ |   +1 Let X=GCD(a,m).So if GCD((a+x)/X,m/X) equals to 1, GCD(a,m) will equal to GCD(a+x,m).
 » 4 weeks ago, # |   +10 I'll bite, how to solve F? :P
 » 4 weeks ago, # |   +3 GG, thanks for all the awesome problems! It was my first time participating in such a coding contest and it did take me some time to get used to many things on Codeforces. As a first-timer, Codeforces is like a gold mine to novice programmers like me xD. Can someone give me a few pointers on how to improve as I found some questions quite challenging and there are always some nuts who can solve them in like 10min :DCheers~
•  » » 4 weeks ago, # ^ |   0 One who uses hakase as profile is always on a roll :)
•  » » » 4 weeks ago, # ^ |   +3 xD ikr
 » 4 weeks ago, # | ← Rev. 2 →   0 How to solve C? My idea was to use hashmap (Key: Value being Char: List of Index) for characters of string S. But got TLE
•  » » 4 weeks ago, # ^ | ← Rev. 4 →   +4 my_submission dp[i][j] -> nearest index of alphabet(j) after index i and iterate through string t and solve problem greedily
•  » » 4 weeks ago, # ^ |   0 Store indexes for every letters 'a' to 'z' from String s. After storing, sort the indexes of individual letters. At first make a variable idx set to 0 before iterating String t. set ans to 0. While iterating on String t, you can check if current character happens from idx to afterwards in String s by just doing binary search on that character's stored indexes. if idx is not found in stored indexes, set idx to 0 again and now it must be found. just increment the ans when idx is not found.just in case when at least one letter in String t is not in String s, then the ans is -1.
•  » » » 4 weeks ago, # ^ |   0 https://codeforces.com/contest/1295/submission/69785885Solved it, but I had to use binary search. But the previous try was in Python, so maybe because it is not required.
•  » » » » 4 weeks ago, # ^ | ← Rev. 2 →   0 Although this algorithm is slow,it can avoid using binary search.
•  » » 4 weeks ago, # ^ |   -19 This question was copied from here not fair:( https://stackoverflow.com/questions/53065084/minimum-no-of-operations-required-to-create-string-a-by-appending-subsequence-of
•  » » » 4 weeks ago, # ^ |   +11 Not only problems but also exercises can be used; Useful, even well-known ideas will be reused in order to introduce them to a wide range of participants; These are some characteristics which education rounds follow.
•  » » » » 4 weeks ago, # ^ |   -20 Ok so indirectly u want to say that in educational rounds before solving any question we should Google it??nice
•  » » » » » 4 weeks ago, # ^ |   +20 Yes you can google and stay green.
•  » » » » » » 4 weeks ago, # ^ |   -12 Ok Mr Red xD
•  » » » » » » » 4 weeks ago, # ^ |   0 Yes you can do it.But are you sure that you can solve the problems even if you google it?So that's the reason why you are staying green.If you still want to stay green,you can google the problems,even if it violates the rules.xD
 » 4 weeks ago, # |   -10 D was similar to https://www.codechef.com/problems/CDZ14D
•  » » 4 weeks ago, # ^ |   -21
 » 4 weeks ago, # |   +95 It might be a very weird thing to ask as an author, but how to solve F?It seems that my model solution is a lot more complicated that the ones from the participants.
•  » » 4 weeks ago, # ^ |   +96 Short solution summary (div1 500)
•  » » » 4 weeks ago, # ^ |   +33 Thank you! It's amazing how the combinatorial approach to the problem can make the solution a lot easier. Unfortunately, I didn't even think about that, and the probabilistic way lead me to maintaining and interpolating the probabilities as polynomials (which is way harder, obviously).
 » 4 weeks ago, # |   +14 Hi, can anybody make a hack? I receive an error after Hack button..
•  » » 4 weeks ago, # ^ |   +9 Me too. The error message "Illegal Contest ID" is shown
•  » » » 4 weeks ago, # ^ |   +12 Open the solution by clicking on its id and the click hackit
•  » » » » 4 weeks ago, # ^ |   +1 Thank you!
•  » » 4 weeks ago, # ^ |   +3 Me too.
•  » » 4 weeks ago, # ^ |   0 Same
 » 4 weeks ago, # |   0 Did you really think this B was appropriate?
•  » » 4 weeks ago, # ^ |   0 ya, yep, yes, yo
 » 4 weeks ago, # |   +40 I just found a cheat in this contest;At "Hacks" page of this contest. I found ma_da_fa_ka and InsaneNerd hacked each other on problem B. Since it's very funny, I looked into their solution and only to discover they copied each other and the both get accepetd in their latest solotion!By the way, ma_da_fa_ka's code even didn't have indentation. By the way, ma_da_fa_ka used bad word as his handle. (lol)
•  » » 4 weeks ago, # ^ |   +2 And one of the funniest thing is that ma_da_fa_ka even tried to hack himself,although that hack was unsuccessful. xD
•  » » 4 weeks ago, # ^ |   0 So why Codeforces can't stop them from cheating?I think that will be a big problem.Wish MikeMirzayanov can manage to stop them.
 » 4 weeks ago, # |   +1 How do I know if D Euler(m / gcd(a,m) )
•  » » 4 weeks ago, # ^ |   +2 Instincts....
•  » » 4 weeks ago, # ^ | ← Rev. 2 →   +17 Let $d = gcd(a, m)$. Since $0≤ x < m$ and $1 <= a < m$, we easily conclude that $(a + x)$ mod $m$ can take values in the range $[0, m - 1]$ and we know that $gcd(a + x, m) = gcd(m, (a+x)\ mod \ m) = d$ Let's look at the case when $d = 1$, let $b = (a + x)\:mod\:m$, our goal is to find all the values of b where $gcd(m, b) = 1$ which is by definition $\phi(m)$ given that we concluded earlier that b can take any value in the range $[0, m - 1]$. Now, let's consider the case where $d \neq 1$. Clearly, the values of b that we are looking for in the range $[0, m - 1]$ must be multiples of $d$, so let's enumerate all the $m / d$ multiples of $d$ in this range as follows: $1, 2, ..., (m / d)$. Let $i$ be the enumeration of the $i^{th}$ multiple, we want to count $i$ such that $gcd(i * d, m) = d$, but since $d \ | \ m \ and \ d \ | \ (i * d)$, we really want to count $i$ such that $gcd(i, m / d) = 1$, which turns out to be $\phi(m / d)$.
•  » » » 4 weeks ago, # ^ |   0 Thank you very much
 » 4 weeks ago, # |   0 Problem is saying 998244353 decimal digits. What i was thinking number should be less than 998244353. Can anyone suggest what should i do to avoid such type of mistakes ???
•  » » 4 weeks ago, # ^ |   +106 Learn to read.
•  » » » 4 weeks ago, # ^ |   +43 Thank you so much.
•  » » 4 weeks ago, # ^ |   0 read the entire statement, it also mentioned Note that the answer may not fit in the standard 32-bit or 64-bit integral data type.
 » 4 weeks ago, # |   -25 Such a bug B!This round shoule be unr!
•  » » 4 weeks ago, # ^ |   -18 Agree, I would have spent years trying to debug my solution if I did not decide that solving C first is a better idea...
 » 4 weeks ago, # |   0 how to solve B?
•  » » 4 weeks ago, # ^ |   +7 You can create an array $cnt_0$ and $cnt_1$ in which $cnt_x[i]$ is the number of characters $x$ are from $0$ to $i$. Also, you can calculate $delta[i]$ which is $cnt_0[i] - cnt_1[i]$. Then, when the string is repeated again, the same pattern of $delta$ is going to occur but increased by a constant, because the number of $0$ and $1$ that you have from the previous string are accumulated. I'm going to concatenate $s$ two times to make the pattern visible. Let's analyze the following input $n = 6, x = 10, s = 010010$ $cnt_0: 1, 1, 2, 3, 3, 4 | 5, 5, 6, 7, 7, 8$ $cnt_1: 0, 1, 1, 1, 2, 2 | 2, 3, 3, 3, 4, 4$ $delta: 1, 0, 1, 2, 1, 2 | 3, 2, 3, 4, 3, 4$ Every time a string has finished, delta is going to change in a constant. Let's called that constant $d = delta[n] - delta[0]$. For each position $i$ between $0$ and $n - 1$, you know that you can reach all the numbers of the form $delta[i] + kd$, in which $k \geq 0$ because it is the number of times that the string is going to be repeated. So, for each $delta[i]$, $i$ between $0$ and $n - 1$, you have to check if it possible to obtain a non negative $k$ such that $x = delta[i] + kd$. The only corner cases are in which $d = 0$, then, if you have at least one solution, you are going to have infinite solutions of this form. Finally, check the case of the empty string if the solution is no infinity. The time complexity is $O(n)$.
•  » » » 4 weeks ago, # ^ |   0 Thank you for the clear explanation.I have somewhat awkward question:Have you seen similar problem before? In other words, do you feel that your experience has helped you to solve it?I was trying really hard to solve it for 90 minutes, but get lost in own thought process. So I wonder if I need more practice or maybe this CP thing is simply not for me ;-).
•  » » 4 weeks ago, # ^ |   0 I don't like problems like today's B where you have to be so careful with corner cases. There isn't any fancy idea behind, just annoying implementation ._.
•  » » 4 weeks ago, # ^ | ← Rev. 2 →   +3 take '0' as $1$ and '1' as $-1$ and calculate the prefix sum $pre$.then for each $pre_i + x\cdot pre_n = balance$_$value$, if there is a non-negative integer $x$ satisfying the formula, add 1 to the answer. if balance_value is zero then add another 1 to the answer.if $pre_n=0$ then if there exists an $pre_i=balance$_$value$, then answer is -1; else answer is 0.
•  » » » 4 weeks ago, # ^ |   0 why add 1 when balance_value is zero?
•  » » » » 4 weeks ago, # ^ |   0 Because empty prefix can be a prefix too. So the balance of empty prefix is 0.
 » 4 weeks ago, # |   +12 VERY VERY WEAK test cases for B :(
 » 4 weeks ago, # |   0 Author is fond of strings i guess.
 » 4 weeks ago, # | ← Rev. 5 →   +5 D can also be solved with mobius function(Inc-Exc) 69790210. Let g = gcd(a,m). gcd(a+x,m) is g if and only if g|x. gcd(a+x,m) = gcd(g*c1 + g*y, g*c2) = g. gcd(c1 + y, c2) = 1. Use inc-exc now — neglect non-square free numbers for others if a divisor is prime product for even number of primes than subtract such numbers, for odd add them using the observation that if mu[n] = mu[d]*mu[n/d].
 » 4 weeks ago, # |   +12 Anybody with a good hack for B?
•  » » 4 weeks ago, # ^ |   +9 2 6 2 001001 3 0 011
•  » » » 4 weeks ago, # ^ |   0 Answer should be 3 3
•  » » » » 4 weeks ago, # ^ |   0 Thanks, some of the hacked solutions fail on this test indeed. Interesting
 » 4 weeks ago, # |   0 How to solve C ?
•  » » 4 weeks ago, # ^ |   0 See 69759300
•  » » 4 weeks ago, # ^ |   0 Let's store index of every letter (in vector, for example). Then, just simulate building of string with fast find of needed index — lower_bound is good for this purposes. 69790270
 » 4 weeks ago, # | ← Rev. 5 →   0 Problem "A" was similar to this problem. Link: www.hackerrank.com/contests/programming-contest-4-cse-ian-of-bd/challenges/number-with-sticks
 » 4 weeks ago, # |   0 I am not sure about my solution,can anybody hack it.
•  » » 4 weeks ago, # ^ |   0 It is correct for sure.
 » 4 weeks ago, # |   -48 that was one of the worst contest in all of the codeforces rounds. the problems were really bad. i hope to see better contest in future.
•  » » 4 weeks ago, # ^ |   +40 why is it really bad? is it because you didn't do well in this contest. what a good contest for you would look like?
•  » » » 4 weeks ago, # ^ |   -17 for starters, a good CF contest wouldn't have more people solving C than B
•  » » » » 4 weeks ago, # ^ | ← Rev. 2 →   +57 so what? the problems in edu rounds are equal (there are no points for problems, ICPC style). so solving C more than B is just a matter of swap. so people should see the number of participants who solve the problem and move to that problem. and being stuck in a problem is no good skill. people need to learn to move on. and even if the problems were given points and people solve c more than b, it does not yield the entire contest bad. you guys just talk trash about the contest while you do not know the efforts made to prepare the rounds. It is a lot harder to estimate how the contest would go for the participants.
•  » » » » » 4 weeks ago, # ^ |   0 That might've worked if they had managed to prepare B well enough to avoid errors in the testcases
•  » » 4 weeks ago, # ^ |   0 Bruh salty. Edus are getting better ever since they reduced it to 6 problems.
•  » » 4 weeks ago, # ^ |   +12 BRs82 was one of the worst person in all of the codeforces users.The comments were really bad.i hope to see better user in future.
 » 4 weeks ago, # |   0 Can someone explain the idea "phi value of m/(gcd(a,m))" for problem D? I mean how we got it?
•  » » 4 weeks ago, # ^ |   +14 This has already been explained in previous comments.Let $gcd(a, m) = g$We have $gcd(a, m) = gcd(a+x, m) = gcd((a+x) \ \% \ m, \ m)$Notice that as $x$ increases, $(a + x) \ \% \ m$ will end up taking all values in $[0, m)$So we only need to find the number of $k \in [0, m)$, such that $gcd(k, m) = g$Since $gcd(ca, cb) = c \iff gcd(a, b) = 1$, we can take any integer coprime to $m/g$ and multiply it by $g$ to find a suitable $k$.
•  » » » 4 weeks ago, # ^ |   0 Got the idea.
•  » » » 4 weeks ago, # ^ |   0 Thx a lot
 » 4 weeks ago, # |   0 will there be points for successful hacking during the hacking phase?
•  » » 4 weeks ago, # ^ | ← Rev. 2 →   -12 The EMPTY STRING is also a valid prefix.It was ensured in the announcement.
•  » » » 4 weeks ago, # ^ |   0 sorry?
•  » » 4 weeks ago, # ^ |   0 Educational CF Round and Div.3 Round have no points for successful hacking attempt.
 » 4 weeks ago, # | ← Rev. 2 →   0 69796073Is it possible to see the hack case for my solution after preliminary result? I really have no idea of the counter example :(
 » 4 weeks ago, # |   0 I solved E without any range updation datastructure , just use map of values which have arrived and changes the current cost with coming elements and decrementing the cost if already added to the initial cost, it gives me wrong answer on testcase 10, can anybody look into it my submission https://codeforces.com/contest/1295/submission/69796456
 » 4 weeks ago, # |   0 Can anyone please tell me what is wrong with my code for problem B. https://codeforces.com/contest/1295/submission/69788305
•  » » 4 weeks ago, # ^ |   0 The EMPTY STRING is also a valid prefix.It was ensured in the announcement.
 » 4 weeks ago, # |   0 A was very similar to 101612A - Auxiliary Project
 » 4 weeks ago, # |   0 What is "Unexpected verdict"? Hack #613188
•  » » 4 weeks ago, # ^ |   0 It means that one of the problem makers' solution is incorrect. (The official solutions had a different answer to each other.)
 » 4 weeks ago, # | ← Rev. 2 →   +14 Didn't know much about such a nice function (Euler Totient Function)Thanx to problem D for increasing my knowledge.
 » 4 weeks ago, # |   0 I think so many TLE codes are "accepted" in Problem C.
•  » » 4 weeks ago, # ^ | ← Rev. 3 →   +6 A very simple testcase in Problem C was hacking testcase for many solutions.1aaaa....a(length is 100000)aaaa....a(length is 100000)If I woke up early, I could do more hacks.
•  » » » 4 weeks ago, # ^ |   0 Why can such codes pass all the test data? Is all the test data random?
•  » » » » 4 weeks ago, # ^ |   0 Yes, Testdata is too week. But it is no matter, because this is an "Educational Contest" which is for not only algorithm ranking but also hacks ranking.
•  » » » 4 weeks ago, # ^ |   0 I think if you hacked at least one problem with this test case, it might be added to final test.
•  » » » » 4 weeks ago, # ^ |   0 True. So the codes get TLE finally anyway. but my hack score ...
 » 4 weeks ago, # |   0 Editorial please?
•  » » 4 weeks ago, # ^ |   0 For problem A,the number has two forms:111...111or7111...111If n is even,the first form is better,otherwise,the second form is better.
•  » » 4 weeks ago, # ^ |   +3 The editorial of B,C and D are showed in former discussions.
•  » » 4 weeks ago, # ^ |   -37 I haven't solved problem E,F yet,so you can ask tourist . :D
•  » » » 4 weeks ago, # ^ |   -12 LOL
 » 4 weeks ago, # |   0 Am I the only 8ne who solved C with a precomputed DP
•  » » 4 weeks ago, # ^ |   +3 Nope,but INMAK also uses DP.
 » 4 weeks ago, # |   +12 When will the system testing start?
 » 4 weeks ago, # |   0 It's pretty.
 » 4 weeks ago, # |   +20 where's the rating Lebowski
 » 4 weeks ago, # |   0 For question B: Can anyone explain why the output of 1 3 0 011 is 2 ? Please help, my solution is hacked and I don't know why
•  » » 4 weeks ago, # ^ |   0 It's 3.
•  » » 4 weeks ago, # ^ |   0 I get it, thanks
•  » » 4 weeks ago, # ^ |   0 There are three prefixes that satisfied the condition:""(EMPTY STRING),"01","0110".
 » 4 weeks ago, # |   0 No matter how hard I try, I could not understand the solutions given for problem D. It would be great if someone could explain me how to do in simple and detailed steps. I would be really grateful to them.Thank you!
•  » » 4 weeks ago, # ^ |   +4 Let X be gcd(a,m),so gcd(a/X,m/X)=1.If gcd(a+x,m)=X,then (a+x)%X equals to 0,x%X also equals to 0.So gcd((a+x)/X,m/X) equals to 1.Find all the x in eular algorithm.
•  » » » 4 weeks ago, # ^ |   0 Finally! got it thank you so much :)
 » 4 weeks ago, # |   +9 when will editorial be published?
 » 4 weeks ago, # |   0 Waiting for the Editorials!!
 » 4 weeks ago, # |   0 Has the editorial for this contest been published yet? Or there won't be one?
•  » » 4 weeks ago, # ^ |   0 It would surely be published. Not sure about the release time.
 » 4 weeks ago, # |   0 expert in a one contest
 » 4 weeks ago, # |   0 Auto comment: topic has been updated by pikmike (previous revision, new revision, compare).
»
4 weeks ago, # |
0

problem A What's wrong in this?

# include<bits/stdc++.h>

using namespace std; long long n; int main(){ int t; cin>>t; while(t--){ cin>>n; if(n%2==0){ for(int i=0; i<(n/2); i++) cout<<"1"; } else{ cout<<"7"; if(n!=3){ for(int i=0; i<((n-1)/2); i++) cout<<"1"; }

}

cout<<endl; }

}

•  » » 4 weeks ago, # ^ |   0 In your loop for(int i=0; i<((n-1)/2); i++), it should be i < (n — 3)/2 instead, as 7 takes 3 resources.
•  » » » 4 weeks ago, # ^ |   0 thanks buddy!!
 » 12 days ago, # |   0 Why is this solution so slow? (Problem C):http://codeforces.com/contest/1295/submission/70937323As for me, the complexity of this one is O(T*|t|*log(|s|))